#==============================================================
#
#  Abs:  Device Support for Agilent 5322 (laser locker)
#
#  Name: Agilent5322.template
#
#  Side:  None
#
#  Facility: LCLS XLEAP
#
#  Auth: dd-mmm-yyyy, Jeremy Mock   (JMOCK):
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#       09-May-2017, J. Mock        (JMOCK):
#         Initial Release
#
#==============================================================

#! Generated by VisualDCT v2.6
#! DBDSTART
#! DBDEND


record(stringin, "OSC:LT10:20:IDENTITY") {
  field(DESC, "Identification")
  field(DTYP, "stream")
  field(INP, "@Agilent5322.proto.db GET_IDN agilFC")
}

record(bo, "OSC:LT10:20:RESET") {
  field(DESC, "Reset command")
  field(DTYP, "stream")
  field(OUT, "@Agilent5322.proto.db RESET agilFC")
  field(FLNK, "OSC:LT10:20:UPDATE")
}

record(fanout, "OSC:LT10:20:UPDATE") {
  field(DESC, "Update all settings")
  field(LNK1, "OSC:LT10:20:GET_IMPEDANCE")
  field(LNK2, "OSC:LT10:20:GET_TRIG_LEVEL")
  field(LNK3, "OSC:LT10:20:GET_TRIG_PERCENT")
  field(LNK4, "OSC:LT10:20:GET_AUTO_LEVEL")
  field(LNK5, "OSC:LT10:20:GET_COUPLING")
  field(LNK6, "OSC:LT10:20:GET_NOISE_REJ")
}

record(ai, "OSC:LT10:20:FREQ_RBCK_RAW") {
  field(DESC, "Measured frequency")
  field(SCAN, "1 second")
  field(DTYP, "stream")
  field(INP, "@Agilent5322.proto.db GET_FREQ agilFC")
  field(EGU, "Hz")
  field(PREC, "3")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calcout, "OSC:LT10:20:FREQ_RBCK_PROC_") {
  field(DESC, "Update only when readback is sensible")
  field(CALC, "A<1000000000")
  field(INPA, "OSC:LT10:20:FREQ_RBCK_RAW CP MS")
  field(OUT, "OSC:LT10:20:FREQ_RBCK PP MS")
  field(OOPT, "When Non-zero")
  field(DOPT, "Use OCAL")
  field(OCAL, "A")
  field(LOW, "0")
  field(LSV, "INVALID")
}

record(ai, "OSC:LT10:20:FREQ_RBCK") {
  field(DESC, "Measured frequency")
  field(EGU, "Hz")
  field(PREC, "3")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(bi, "OSC:LT10:20:GET_IMPEDANCE") {
  field(DESC, "Input Impedance")
  field(DTYP, "stream")
  field(INP, "@Agilent5322.proto.db GET_IMPEDANCE agilFC")
  field(ZNAM, "1M Ohm")
  field(ONAM, "50 Ohm")
  info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SET_IMPEDANCE") {
  field(DESC, "Input Impedance")
  field(DTYP, "stream")
  field(OUT, "@Agilent5322.proto.db SET_IMPEDANCE agilFC")
  field(ZNAM, "1M Ohm")
  field(ONAM, "50 Ohm")
  field(FLNK, "OSC:LT10:20:GET_IMPEDANCE")
  info(autosaveFields, "VAL ZSV OSV")
}

record(ai, "OSC:LT10:20:GET_TRIG_LEVEL") {
  field(DESC, "Trigger level")
  field(DTYP, "stream")
  field(INP, "@Agilent5322.proto.db GET_TRIG_LEVEL agilFC")
  field(EGU, "V")
  field(PREC, "3")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SET_TRIG_LEVEL") {
  field(DESC, "Trigger level")
  field(DTYP, "stream")
  field(OUT, "@Agilent5322.proto.db SET_TRIG_LEVEL agilFC")
  field(EGU, "V")
  field(PREC, "3")
  field(FLNK, "OSC:LT10:20:GET_TRIG_LEVEL")
  info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ai, "OSC:LT10:20:GET_TRIG_PERCENT") {
  field(DESC, "Trigger percent")
  field(DTYP, "stream")
  field(INP, "@Agilent5322.proto.db GET_TRIG_PERCENT agilFC")
  field(EGU, "V")
  field(PREC, "3")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SET_TRIG_PERCENT") {
  field(DESC, "Trigger percent")
  field(DTYP, "stream")
  field(OUT, "@Agilent5322.proto.db SET_TRIG_PERCENT agilFC")
  field(EGU, "V")
  field(PREC, "3")
  field(FLNK, "OSC:LT10:20:GET_TRIG_PERCENT")
  info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(mbbi, "OSC:LT10:20:GET_AUTO_LEVEL") {
  field(DESC, "Input AUTO_LEVEL")
  field(DTYP, "stream")
  field(INP, "@Agilent5322.proto.db GET_AUTO_LEVEL agilFC")
  field(ZRST, "OFF")
  field(ONST, "ON")
  field(TWST, "ONCE")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV")
}

record(mbbo, "OSC:LT10:20:SET_AUTO_LEVEL") {
  field(DESC, "Input AUTO_LEVEL")
  field(DTYP, "stream")
  field(OUT, "@Agilent5322.proto.db SET_AUTO_LEVEL agilFC")
  field(ZRST, "OFF")
  field(ONST, "ON")
  field(TWST, "ONCE")
  field(FLNK, "OSC:LT10:20:GET_AUTO_LEVEL")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV")
}

record(bi, "OSC:LT10:20:GET_COUPLING") {
  field(DESC, "Input Coupling")
  field(DTYP, "stream")
  field(INP, "@Agilent5322.proto.db GET_COUPLING agilFC")
  field(ZNAM, "AC")
  field(ONAM, "DC")
  info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SET_COUPLING") {
  field(DESC, "Input Coupling")
  field(DTYP, "stream")
  field(OUT, "@Agilent5322.proto.db SET_COUPLING agilFC")
  field(ZNAM, "AC")
  field(ONAM, "DC")
  field(FLNK, "OSC:LT10:20:GET_COUPLING")
  info(autosaveFields, "VAL ZSV OSV")
}

record(bi, "OSC:LT10:20:GET_NOISE_REJ") {
  field(DESC, "Noise rejection")
  field(DTYP, "stream")
  field(INP, "@Agilent5322.proto.db GET_NOISE_REJ agilFC")
  field(ZNAM, "OFF")
  field(ONAM, "ON")
  info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SET_NOISE_REJ") {
  field(DESC, "Noise rejection")
  field(DTYP, "stream")
  field(OUT, "@Agilent5322.proto.db SET_NOISE_REJ agilFC")
  field(ZNAM, "OFF")
  field(ONAM, "ON")
  field(FLNK, "OSC:LT10:20:GET_NOISE_REJ")
  info(autosaveFields, "VAL ZSV OSV")
}

#! Further lines contain data used by VisualDCT
#! View(0,0,1.0)
#! Record("OSC:LT10:20:IDENTITY",20,22,0,0,"OSC:LT10:20:IDENTITY")
#! Record("OSC:LT10:20:RESET",500,22,0,0,"OSC:LT10:20:RESET")
#! Record("OSC:LT10:20:FREQ_RBCK_RAW",80,200,0,0,"OSC:LT10:20:FREQ_RBCK_RAW")
#! Field("OSC:LT10:20:FREQ_RBCK_RAW.VAL",16777215,1,"OSC:LT10:20:FREQ_RBCK_RAW.VAL")
#! Record("OSC:LT10:20:FREQ_RBCK_PROC_",340,159,0,1,"OSC:LT10:20:FREQ_RBCK_PROC_")
#! Field("OSC:LT10:20:FREQ_RBCK_PROC_.INPA",16777215,0,"OSC:LT10:20:FREQ_RBCK_PROC_.INPA")
#! Link("OSC:LT10:20:FREQ_RBCK_PROC_.INPA","OSC:LT10:20:FREQ_RBCK_RAW.VAL")
#! Field("OSC:LT10:20:FREQ_RBCK_PROC_.OUT",16777215,1,"OSC:LT10:20:FREQ_RBCK_PROC_.OUT")
#! Link("OSC:LT10:20:FREQ_RBCK_PROC_.OUT","OSC:LT10:20:FREQ_RBCK.VAL")
#! Record("OSC:LT10:20:FREQ_RBCK",680,262,0,1,"OSC:LT10:20:FREQ_RBCK")
#! Field("OSC:LT10:20:FREQ_RBCK.VAL",16777215,0,"OSC:LT10:20:FREQ_RBCK.VAL")
record(asyn,"SIOC:LR10:LS02_A:ASYNDRIVER")
{
    field(DTYP,"asynRecordDevice")
    field(PORT,"DIGI_MEI_Serial16")
    field(ADDR,"0")
    field(OMAX,"0")
    field(IMAX,"0")
}

# Record Database template for SRS SR620 Universal Time Interval Counter
# Based partly on dhzhang's SMC100 implementation
# Author: Karl Gumerlock (klg)

# Debug record
record(stringout, "OSC:LT10:20:SendDebug") {
    field(DESC, "Send debug command")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db sendDebug() OSC:LT10:20")
}

# Periodic update record - EVNT#1
# All readback values are keyed on this record's SCAN period using a fanout
record(event, "OSC:LT10:20:UpdateAll") {
    field(DESC, "Update all periodic RBvalues")
    field(DTYP, "Soft Channel")
    field(VAL,  "1")
    field(SCAN, "10 second")
    field(FLNK, "OSC:LT10:20:UpdateAll:FRoot")
    field(PINI, "YES")
	info(autosaveFields, "SCAN")
}

record(fanout, "OSC:LT10:20:UpdateAll:FRoot") {
    field(DESC, "UpdateAll root fanout")
    field(LNK1, "OSC:LT10:20:UpdateAll:F1")
    field(LNK2, "OSC:LT10:20:UpdateAll:F2")
    field(LNK3, "OSC:LT10:20:UpdateAll:F3")
    field(LNK4, "OSC:LT10:20:UpdateAll:F4")
    field(LNK5, "OSC:LT10:20:UpdateAll:F5")
    field(LNK6, "OSC:LT10:20:UpdateAll:F6")
}

record(fanout, "OSC:LT10:20:UpdateAll:F1") {
    field(DESC, "UpdateAll fanout 1")
    field(LNK1, "OSC:LT10:20:UpdateAll:F1:1")
    field(LNK2, "OSC:LT10:20:UpdateAll:F1:2")
    field(LNK3, "OSC:LT10:20:UpdateAll:F1:3")
    field(LNK4, "OSC:LT10:20:UpdateAll:F1:4")
    field(LNK5, "OSC:LT10:20:UpdateAll:F1:5")
}

record(fanout, "OSC:LT10:20:UpdateAll:F1:1") {
    field(DESC, "UpdateAll fanout 1.1")
    field(LNK1, "OSC:LT10:20:A:GetTrigThreshold")
    field(LNK2, "OSC:LT10:20:B:GetTrigThreshold")
    field(LNK3, "OSC:LT10:20:GetRefLvlAmp")
    field(LNK4, "OSC:LT10:20:A:GetInputCoupl")
    field(LNK5, "OSC:LT10:20:B:GetInputCoupl")
    field(LNK6, "OSC:LT10:20:EXT:GetInputTerm")
}

record(fanout, "OSC:LT10:20:UpdateAll:F1:2") {
    field(DESC, "UpdateAll fanout 1.2")
    field(LNK1, "OSC:LT10:20:DAC1:GetScanStepSize")
    field(LNK2, "OSC:LT10:20:GetAutoprintMode")

    field(LNK4, "OSC:LT10:20:GetDisplayGraphType")
    field(LNK5, "OSC:LT10:20:GetGraphEnable")
    field(LNK6, "OSC:LT10:20:GetGraphScaleHistV")
}

record(fanout, "OSC:LT10:20:UpdateAll:F1:3") {
    field(DESC, "UpdateAll fanout 1.3")
    field(LNK1, "OSC:LT10:20:GetGraphScaleHistH")
    field(LNK2, "OSC:LT10:20:GetGraphScaleHistB")
    field(LNK3, "OSC:LT10:20:GetGraphScaleMean")
    field(LNK4, "OSC:LT10:20:GetGraphScaleJitter")
    field(LNK5, "OSC:LT10:20:GetPrintingDevice")
    field(LNK6, "OSC:LT10:20:GetPlotterAddress")
}

record(fanout, "OSC:LT10:20:UpdateAll:F1:4") {
    field(DESC, "UpdateAll fanout 1.4")
    field(LNK1, "OSC:LT10:20:GetPlotterPort")
    field(LNK2, "OSC:LT10:20:GetDisplaySource")
    field(LNK3, "OSC:LT10:20:GetExpandMode")
    field(LNK4, "OSC:LT10:20:GetLastKeyPressed")
    field(LNK5, "OSC:LT10:20:GetClockSource")
    field(LNK6, "OSC:LT10:20:GetClockFreq")
}

record(fanout, "OSC:LT10:20:UpdateAll:F1:5") {
    field(DESC, "UpdateAll fanout 1.5")
    field(LNK1, "OSC:LT10:20:GetPrinterPortMode")
    field(LNK2, "OSC:LT10:20:DVM0:GetVRange")
    field(LNK3, "OSC:LT10:20:DVM1:GetVRange")
    field(LNK4, "OSC:LT10:20:DVM0:GetV")
    field(LNK5, "OSC:LT10:20:DVM1:GetV")
}

record(fanout, "OSC:LT10:20:UpdateAll:F2") {
    field(DESC, "UpdateAll fanout 2")
    field(LNK1, "OSC:LT10:20:A:GetInputTerm")
    field(LNK2, "OSC:LT10:20:B:GetInputTerm")
    field(LNK3, "OSC:LT10:20:A:GetTrigMode")
    field(LNK4, "OSC:LT10:20:B:GetTrigMode")
    field(LNK5, "OSC:LT10:20:EXT:GetTrigSlope")
    field(LNK6, "OSC:LT10:20:A:GetTrigSlope")
}

record(fanout, "OSC:LT10:20:UpdateAll:F3") {
    field(DESC, "UpdateAll fanout 3")
    field(LNK1, "OSC:LT10:20:B:GetTrigSlope")
    field(LNK2, "OSC:LT10:20:GetArmMode")
    field(LNK3, "OSC:LT10:20:GetAutoMeasMode")
    field(LNK4, "OSC:LT10:20:GetDispRELMode")
    field(LNK5, "OSC:LT10:20:GetGatePeriod:Update")
    field(LNK6, "OSC:LT10:20:GetVarianceType")
}

record(fanout, "OSC:LT10:20:UpdateAll:F4") {
    field(DESC, "UpdateAll fanout 4")
    field(LNK1, "OSC:LT10:20:GetInstrumentMode")
    field(LNK2, "OSC:LT10:20:GetSampleSize")
    field(LNK3, "OSC:LT10:20:GetMeasSource")
#    field(LNK4, "OSC:LT10:20:ProcMeasAll")
    field(LNK5, "OSC:LT10:20:GetDispREL")
    field(LNK6, "OSC:LT10:20:GetDACOutputMode")
}

record(fanout, "OSC:LT10:20:UpdateAll:F5") {
    field(DESC, "UpdateAll fanout 5")
    field(LNK1, "OSC:LT10:20:GetDelayStartPos")
    field(LNK2, "OSC:LT10:20:GetDelayScanMode")
    field(LNK3, "OSC:LT10:20:GetDelayScanStepSize")
    field(LNK4, "OSC:LT10:20:GetScanHoldTime")
    field(LNK5, "OSC:LT10:20:GetScanMode")
    field(LNK6, "OSC:LT10:20:GetLastScanPoint")
}

record(fanout, "OSC:LT10:20:UpdateAll:F6") {
    field(DESC, "UpdateAll fanout 6")
    field(LNK1, "OSC:LT10:20:GetNumScanPoints")
    field(LNK2, "OSC:LT10:20:DAC0:GetScanStartV")
    field(LNK3, "OSC:LT10:20:DAC1:GetScanStartV")
    field(LNK4, "OSC:LT10:20:DAC0:GetOutputV")
    field(LNK5, "OSC:LT10:20:DAC1:GetOutputV")
    field(LNK6, "OSC:LT10:20:DAC0:GetScanStepSize")
}

# High speed update record - EVNT#2
# Readback values that need to be on a faster update rate are keyed to this
# record's SCAN period using a fanout - OK to double up with event 1
record(event, "OSC:LT10:20:UpdateHighRate") {
    field(DESC, "Update RBvalues at hi rate")
    field(DTYP, "Soft Channel")
    field(VAL,  "2")
    field(FLNK, "OSC:LT10:20:UpdateHighRate:FRoot")
    field(SCAN, "1 second")
	info(autosaveFields, "SCAN")
}

record(fanout, "OSC:LT10:20:UpdateHighRate:FRoot") {
    field(DESC, "UpdateHighRate fanout root")
    field(LNK1, "OSC:LT10:20:ProcMeasAll")
}

# Read the identification string from the SR620
record(stringin, "OSC:LT10:20:IDStr") {
    field(DESC, "SR620 ID String")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readStr(*IDN) OSC:LT10:20")
    field(PINI, "YES")
}

# Execute a soft-reset using the *RST command
# This should probably forward link to any readback record
record(bo, "OSC:LT10:20:Reset") {
    field(DESC, "Soft-reset SR620 controller")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(*RST) OSC:LT10:20")
}

# Execute a self-test using the *TST command - if no error, returns 0
record(ao, "OSC:LT10:20:ExecSelfTest") {
    field(DESC, "Execute a self-test")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db readInt(*TST) OSC:LT10:20")
}

# Trigger threshold for A/B LEVL
record(ao, "OSC:LT10:20:A:SetTrigThreshold") {
    field(DESC, "Set Chan A Trigger Threshold")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanFloat(LEVL,1) OSC:LT10:20")
    field(PREC, "2")
    field(EGU,  "V")
    field(FLNK, "OSC:LT10:20:A:GetTrigThreshold")
	info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ai, "OSC:LT10:20:A:GetTrigThreshold") {
    field(DESC, "Get Chan A Trigger Threshold")
    field(DTYP, "stream")
    field(PREC, "2")
    field(EGU,  "V")
    field(INP,  "@sr620.proto.db readChanFloat(LEVL,1) OSC:LT10:20")
	info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ao, "OSC:LT10:20:B:SetTrigThreshold") {
    field(DESC, "Set Chan B Trigger Threshold")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanFloat(LEVL,2) OSC:LT10:20")
    field(PREC, "2")
    field(EGU,  "V")
    field(FLNK, "OSC:LT10:20:B:GetTrigThreshold")
	info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ai, "OSC:LT10:20:B:GetTrigThreshold") {
    field(DESC, "Get Chan B Trigger Threshold")
    field(DTYP, "stream")
    field(PREC, "2")
    field(EGU,  "V")
    field(INP,  "@sr620.proto.db readChanFloat(LEVL,2) OSC:LT10:20")
	info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

# Manual Trigger MTRG
record(bo, "OSC:LT10:20:ManualTrigger") {
    field(DESC, "Manual Trigger")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(MTRG) OSC:LT10:20")
    field(ZNAM, "Stop Gate")
    field(ONAM, "Start Gate")
}

# Front Panel Reference Level Amplitude RLVL
record(bo, "OSC:LT10:20:SetRefLvlAmp") {
    field(DESC, "Set Front Panel Ref Lvl Amp")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(RLVL) OSC:LT10:20")
    field(ZNAM, "ECL")
    field(ONAM, "TTL")
    field(FLNK, "OSC:LT10:20:GetRefLvlAmp")
	info(autosaveFields, "VAL ZSV OSV")
}

record(bi, "OSC:LT10:20:GetRefLvlAmp") {
    field(DESC, "Get Front Panel Ref Lvl Amp")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(RLVL) OSC:LT10:20")
    field(ZNAM, "ECL")
    field(ONAM, "TTL")
	info(autosaveFields, "ZSV OSV")
}

# AC/DC Coupling of Channel A and B inputs TCPL
record(bo, "OSC:LT10:20:A:SetInputCoupl") {
    field(DESC, "Set Chan A Inp AC/DC Coupl")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(TCPL,1) OSC:LT10:20")
    field(ZNAM, "DC")
    field(ONAM, "AC")
    field(FLNK, "OSC:LT10:20:A:GetInputCoupl")
	info(autosaveFields, "VAL ZSV OSV")
}

record(bi, "OSC:LT10:20:A:GetInputCoupl") {
    field(DESC, "Get Chan A Inp AC/DC Coupl")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(TCPL,1) OSC:LT10:20")
    field(ZNAM, "DC")
    field(ONAM, "AC")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:B:SetInputCoupl") {
    field(DESC, "Set Chan B Inp AC/DC Coupl")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(TCPL,2) OSC:LT10:20")
    field(ZNAM, "DC")
    field(ONAM, "AC")
    field(FLNK, "OSC:LT10:20:B:GetInputCoupl")
	info(autosaveFields, "VAL ZSV OSV")
}

record(bi, "OSC:LT10:20:B:GetInputCoupl") {
    field(DESC, "Get Chan B Inp AC/DC Coupl")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(TCPL,2) OSC:LT10:20")
    field(ZNAM, "DC")
    field(ONAM, "AC")
	info(autosaveFields, "ZSV OSV")
}

# Input Termination of EXT, A, B inputs TERM
record(mbbo, "OSC:LT10:20:EXT:SetInputTerm") {
    field(DESC, "Set EXT Input Termination")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(TERM,0) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "50 Ohm")
    field(ONST, "1 MOhm")
    field(TWST, "UHF Prescalers")
    field(FLNK, "OSC:LT10:20:EXT:GetInputTerm")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV")
}

record(mbbi, "OSC:LT10:20:EXT:GetInputTerm") {
    field(DESC, "Get EXT Input Termination")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(TERM,0) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "50 Ohm")
    field(ONST, "1 MOhm")
    field(TWST, "UHF Prescalers")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV")
}

record(mbbo, "OSC:LT10:20:A:SetInputTerm") {
    field(DESC, "Set A Input Termination")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(TERM,1) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "50 Ohm")
    field(ONST, "1 MOhm")
    field(TWST, "UHF Prescalers")
    field(FLNK, "OSC:LT10:20:A:GetInputTerm")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV")
}

record(mbbi, "OSC:LT10:20:A:GetInputTerm") {
    field(DESC, "Get A Input Termination")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(TERM,1) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "50 Ohm")
    field(ONST, "1 MOhm")
    field(TWST, "UHF Prescalers")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV")
}

record(mbbo, "OSC:LT10:20:B:SetInputTerm") {
    field(DESC, "Set B Input Termination")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(TERM,2) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "50 Ohm")
    field(ONST, "1 MOhm")
    field(TWST, "UHF Prescalers")
    field(FLNK, "OSC:LT10:20:B:GetInputTerm")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV")
}

record(mbbi, "OSC:LT10:20:B:GetInputTerm") {
    field(DESC, "Get B Input Termination")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(TERM,2) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "50 Ohm")
    field(ONST, "1 MOhm")
    field(TWST, "UHF Prescalers")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV")
}

# Trigger Mode of A/B Inputs TMOD
record(bo, "OSC:LT10:20:A:SetTrigMode") {
    field(DESC, "Set A Trigger Mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(TMOD,1) OSC:LT10:20")
    field(ZNAM, "NORMAL")
    field(ONAM, "AUTOLEVEL")
    field(FLNK, "OSC:LT10:20:A:GetTrigMode")
	info(autosaveFields, "VAL ZSV OSV")
}

record(bi, "OSC:LT10:20:A:GetTrigMode") {
    field(DESC, "Get A Trigger Mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(TMOD,1) OSC:LT10:20")
    field(ZNAM, "NORMAL")
    field(ONAM, "AUTOLEVEL")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:B:SetTrigMode") {
    field(DESC, "Set B Trigger Mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(TMOD,2) OSC:LT10:20")
    field(ZNAM, "NORMAL")
    field(ONAM, "AUTOLEVEL")
    field(FLNK, "OSC:LT10:20:B:GetTrigMode")
	info(autosaveFields, "VAL ZSV OSV")
}

record(bi, "OSC:LT10:20:B:GetTrigMode") {
    field(DESC, "Get B Trigger Mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(TMOD,2) OSC:LT10:20")
    field(ZNAM, "NORMAL")
    field(ONAM, "AUTOLEVEL")
	info(autosaveFields, "VAL ZSV OSV")
}

# Trigger Slope of EXT/A/B Inputs TSLP
record(bo, "OSC:LT10:20:EXT:SetTrigSlope") {
    field(DESC, "Set EXT Trigger Slope")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(TSLP,0) OSC:LT10:20")
    field(ZNAM, "POSITIVE")
    field(ONAM, "NEGATIVE")
    field(FLNK, "OSC:LT10:20:EXT:GetTrigSlope")
	info(autosaveFields, "VAL ZSV OSV")
}

record(bi, "OSC:LT10:20:EXT:GetTrigSlope") {
    field(DESC, "Get EXT Trigger Slope")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(TSLP,0) OSC:LT10:20")
    field(ZNAM, "POSITIVE")
    field(ONAM, "NEGATIVE")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:A:SetTrigSlope") {
    field(DESC, "Set A Trigger Slope")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(TSLP,1) OSC:LT10:20")
    field(ZNAM, "POSITIVE")
    field(ONAM, "NEGATIVE")
    field(FLNK, "OSC:LT10:20:A:GetTrigSlope")
	info(autosaveFields, "VAL ZSV OSV")
}

record(bi, "OSC:LT10:20:A:GetTrigSlope") {
    field(DESC, "Get A Trigger Slope")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(TSLP,1) OSC:LT10:20")
    field(ZNAM, "POSITIVE")
    field(ONAM, "NEGATIVE")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:B:SetTrigSlope") {
    field(DESC, "Set B Trigger Slope")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(TSLP,2) OSC:LT10:20")
    field(ZNAM, "POSITIVE")
    field(ONAM, "NEGATIVE")
    field(FLNK, "OSC:LT10:20:B:GetTrigSlope")
	info(autosaveFields, "VAL ZSV OSV")
}

record(bi, "OSC:LT10:20:B:GetTrigSlope") {
    field(DESC, "Get B Trigger Slope")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(TSLP,2) OSC:LT10:20")
    field(ZNAM, "POSITIVE")
    field(ONAM, "NEGATIVE")
	info(autosaveFields, "ZSV OSV")
}


# Device trigger (same as pushing start button) *TRG
record(bo, "OSC:LT10:20:DeviceTrigger") {
    field(DESC, "Device trigger (START btn)")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(*TRG) OSC:LT10:20")
}

# Start button STRT
record(bo, "OSC:LT10:20:StartButton") {
    field(DESC, "Push START button")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(STRT) OSC:LT10:20")
}

# Stop button STOP
record(bo, "OSC:LT10:20:StopButton") {
    field(DESC, "Push STOP button")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(STOP) OSC:LT10:20")
}

# Arming mode ARMM
record(mbbi, "OSC:LT10:20:GetArmMode") {
    field(DESC, "Get current arming mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(ARMM) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(FRVL, "4")
    field(FVVL, "5")
    field(SXVL, "6")
    field(SVVL, "7")
    field(EIVL, "8")
    field(NIVL, "9")
    field(TEVL, "10")
    field(ELVL, "11")
    field(TVVL, "12")
    field(ZRST, "+-time")
    field(ONST, "+ time")
    field(TWST, "1 period")
    field(THST, "0.01 s gate")
    field(FRST, "0.1 s gate")
    field(FVST, "1.0 s gate")
    field(SXST, "ext trg += time")
    field(SVST, "ext trig + time")
    field(EIST, "ext gate/trg HO")
    field(NIST, "ext 1period")
    field(TEST, "ext 0.01 s gate")
    field(ELST, "ext 0.1 s gate")
    field(TVST, "ext 1.0 s gate")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV THSV FRSV FVSV SXSV SVSV EISV NISV TESV ELSV TVSV")
}

record(mbbo, "OSC:LT10:20:SetArmMode") {
    field(DESC, "Set current arming mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(ARMM) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(FRVL, "4")
    field(FVVL, "5")
    field(SXVL, "6")
    field(SVVL, "7")
    field(EIVL, "8")
    field(NIVL, "9")
    field(TEVL, "10")
    field(ELVL, "11")
    field(TVVL, "12")
    field(ZRST, "+-time")
    field(ONST, "+ time")
    field(TWST, "1 period")
    field(THST, "0.01 s gate")
    field(FRST, "0.1 s gate")
    field(FVST, "1.0 s gate")
    field(SXST, "ext trg += time")
    field(SVST, "ext trig + time")
    field(EIST, "ext gate/trg HO")
    field(NIST, "ext 1period")
    field(TEST, "ext 0.01 s gate")
    field(ELST, "ext 0.1 s gate")
    field(TVST, "ext 1.0 s gate")
    field(FLNK, "OSC:LT10:20:GetArmMode")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV THSV FRSV FVSV SXSV SVSV EISV NISV TESV ELSV TVSV")
}

# Autostart of Measurements AUTM
record(bi, "OSC:LT10:20:GetAutoMeasMode") {
    field(DESC, "Get auto measurement mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(AUTM) OSC:LT10:20")
    field(ZNAM, "OFF")
    field(ONAM, "ON")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SetAutoMeasMode") {
    field(DESC, "Set auto measurement mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(AUTM) OSC:LT10:20")
    field(ZNAM, "OFF")
    field(ONAM, "ON")
    field(FLNK, "OSC:LT10:20:GetAutoMeasMode")
	info(autosaveFields, "VAL ZSV OSV")
}

# Toggle complements parity in +-time arming COMP
# Oddly, this command changes a setting with no readback ability
record(bo, "OSC:LT10:20:CompParity") {
    field(DESC, "Toggle complements parity")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(COMP) OSC:LT10:20")
	info(autosaveFields, "VAL ZSV OSV")
}

# Display REL setting DREL
record(mbbi, "OSC:LT10:20:GetDispRELMode") {
    field(DESC, "Get display REL mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(DREL) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(ZRST, "clear")
    field(ONST, "set")
    field(TWST, "clr REL & disp")
    field(THST, "REL=cursor pos")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV THSV")
}

record(mbbo, "OSC:LT10:20:SetDispRELMode") {
    field(DESC, "Set display REL mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(DREL) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(ZRST, "clear")
    field(ONST, "set")
    field(TWST, "clr REL & disp")
    field(THST, "REL=cursor pos")
    field(FLNK, "OSC:LT10:20:GetDispRELMode")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV THSV")
}

# Period of count gate GATE
# This will only accept specific values:
# "x may be between 1us and 500s in a 1,2,5 sequence. if x<0 an externally
#  triggered gate of length x is set."
# SR620 only replies if measurement Mode is PERIOD or COUNT.
record(ai, "OSC:LT10:20:GetGatePeriod") {
    field(DESC, "Get count gate period [s]")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readFloat(GATE) OSC:LT10:20")
    field(EGU,  "s")
	field(PINI, "YES")
	info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(calcout, "OSC:LT10:20:GetGatePeriod:Update") {
	field( DESC, "Ck if we can query" )
	field( INPA, "OSC:LT10:20:GetInstrumentMode NPP" )
	field( CALC, "A==4||A==6" )
	field( OOPT, "When Non-zero" )
	field( OUT,  "OSC:LT10:20:GetGatePeriod.PROC PP NMS" )
}

record(ao, "OSC:LT10:20:SetGatePeriod") {
    field(DESC, "Set count gate period [s]")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeFloat(GATE) OSC:LT10:20")
    field(DRVH, "500")
    field(DRVL, "0.000001")
    field(EGU,  "s")
    field(FLNK, "OSC:LT10:20:GetGatePeriod:Update")
	info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

# Variance type (jitter calculation)  JTTR
record(bi, "OSC:LT10:20:GetVarianceType") {
    field(DESC, "Get var type (jitter calc)")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(JTTR) OSC:LT10:20")
    field(ZNAM, "std dev")
    field(ONAM, "Allan variance")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SetVarianceType") {
    field(DESC, "Set var type (jitter calc)")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(JTTR) OSC:LT10:20")
    field(ZNAM, "std dev")
    field(ONAM, "Allan variance")
    field(FLNK, "OSC:LT10:20:GetVarianceType")
	info(autosaveFields, "VAL ZSV OSV")
}

# Instrument mode MODE
record(mbbi, "OSC:LT10:20:GetInstrumentMode") {
    field(DESC, "Get instrument mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(MODE) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(FRVL, "4")
    field(FVVL, "5")
    field(SXVL, "6")
    field(ZRST, "TIME")
    field(ONST, "WIDTH")
    field(TWST, "TR/TF")
    field(THST, "FREQ")
    field(FRST, "PERIOD")
    field(FVST, "PHASE")
    field(SXST, "COUNT")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV THSV FRSV FVSV SXSV")
}

record(mbbo, "OSC:LT10:20:SetInstrumentMode") {
    field(DESC, "Set instrument mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(MODE) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(FRVL, "4")
    field(FVVL, "5")
    field(SXVL, "6")
    field(ZRST, "TIME")
    field(ONST, "WIDTH")
    field(TWST, "TR/TF")
    field(THST, "FREQ")
    field(FRST, "PERIOD")
    field(FVST, "PHASE")
    field(SXST, "COUNT")
    field(FLNK, "OSC:LT10:20:GetInstrumentMode")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV THSV FRSV FVSV SXSV")
}

# Number of samples in a measurement SIZE
# This will only accept specific values:
# "The parameter x may be between 1 and 10^6 in a 1,2,5 sequence."
record(ai, "OSC:LT10:20:GetSampleSize") {
    field(DESC, "Get sample size (count)")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readFloat(SIZE) OSC:LT10:20")
	info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ao, "OSC:LT10:20:SetSampleSize") {
    field(DESC, "Set sample size (count)")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeFloat(SIZE) OSC:LT10:20")
    field(DRVH, "1000000")
    field(DRVL, "1")
    field(FLNK, "OSC:LT10:20:GetSampleSize")
	info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

# Measurement source setting SRCE
record(mbbi, "OSC:LT10:20:GetMeasSource") {
    field(DESC, "Get measurement source")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(SRCE) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(ZRST, "A")
    field(ONST, "B")
    field(TWST, "REF")
    field(THST, "ratio")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV THSV")
}

record(mbbo, "OSC:LT10:20:SetMeasSource") {
    field(DESC, "Set measurement source")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(SRCE) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(ZRST, "A")
    field(ONST, "B")
    field(TWST, "REF")
    field(THST, "ratio")
    field(FLNK, "OSC:LT10:20:GetMeasSource")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV THSV")
}


# Start a measurement and return the result MEAS
# Four different kinds of gets, split up just like channels
record(ai, "OSC:LT10:20:StartMeasGetMean") {
    field(DESC, "Start meas., get mean")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(MEAS,0) OSC:LT10:20")
	info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ai, "OSC:LT10:20:StartMeasGetJitter") {
    field(DESC, "Start meas., get jitter")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(MEAS,1) OSC:LT10:20")
	info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ai, "OSC:LT10:20:StartMeasGetMax") {
    field(DESC, "Start meas., get max")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(MEAS,2) OSC:LT10:20")
	info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ai, "OSC:LT10:20:StartMeasGetMin") {
    field(DESC, "Start meas., get min")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(MEAS,3) OSC:LT10:20")
	info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}


# Start a measurement using MEAS
# This is probably the better record to use, because it is an output record
# and doesn't realy on setting PROC to 1 to process
record(bo, "OSC:LT10:20:StartMeasurement") {
    field(DESC, "Start measurement")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(MEAS?) OSC:LT10:20")
    field(FLNK, "OSC:LT10:20:ProcMeasAll")
}

# TODO record that StartMeasurement FLNKs to that grabs all of the resulting
# data using XALL? and shoves it into the correct records
record(fanout, "OSC:LT10:20:ProcMeasAll") {
    field(DESC, "Process all measurements")
    field(LNK1, "OSC:LT10:20:GetMeasMean")
    field(LNK2, "OSC:LT10:20:GetMeasJitter")
    field(LNK3, "OSC:LT10:20:GetMeasMax")
    field(LNK4, "OSC:LT10:20:GetMeasMin")
}

# Average (mean) of the last measurement XAVG
record(ai, "OSC:LT10:20:GetMeasMean") {
    field(DESC, "Last measurement mean")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readFloat(XAVG) OSC:LT10:20")
    field(LSV,  "MINOR")
    field(HSV,  "MINOR")
    field(EGU,  "s")
    field(PREC, "12")
    field(FLNK, "OSC:LT10:20:GetOffsetInvMeasMean")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calcout, "OSC:LT10:20:GetMeasMean_nscalc") {
	field( DESC, "Measured mean in ns" )
	field( INPA, "OSC:LT10:20:GetMeasMean CPP MS" )
	field( CALC, "A*1e9" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_ns PP MS" )
}
record(ai, "OSC:LT10:20:GetMeasMean_ns") {
    field(DESC, "Last measurement mean")
    field(EGU,  "ns")
    field(PREC, "6")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Jitter of the last measurement XJIT
record(ai, "OSC:LT10:20:GetMeasJitter") {
    field(DESC, "Last measurement jitter")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readFloat(XJIT) OSC:LT10:20")
    field(LSV,  "MINOR")
    field(HSV,  "MINOR")
    field(EGU,  "s")
    field(PREC, "12")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calcout, "OSC:LT10:20:GetMeasJitter_nscalc") {
	field( DESC, "Measured jitter in ns" )
	field( INPA, "OSC:LT10:20:GetMeasJitter CPP MS" )
	field( CALC, "A*1e9" )
	field( OUT,  "OSC:LT10:20:GetMeasJitter_ns PP MS" )
}
record(ai, "OSC:LT10:20:GetMeasJitter_ns") {
    field(DESC, "Last measurement jitter")
    field(EGU,  "ns")
    field(PREC, "6")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Max of the last measurement XMAX
record(ai, "OSC:LT10:20:GetMeasMax") {
    field(DESC, "Last measurement maximum")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readFloat(XMAX) OSC:LT10:20")
    field(LSV,  "MINOR")
    field(HSV,  "MINOR")
    field(EGU,  "s")
    field(PREC, "12")
    field(FLNK, "OSC:LT10:20:GetOffsetInvMeasMax")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calcout, "OSC:LT10:20:GetMeasMax_nscalc") {
	field( DESC, "Measured Max in ns" )
	field( INPA, "OSC:LT10:20:GetMeasMax CPP MS" )
	field( CALC, "A*1e9" )
	field( OUT,  "OSC:LT10:20:GetMeasMax_ns PP MS" )
}
record(ai, "OSC:LT10:20:GetMeasMax_ns") {
    field(DESC, "Last measurement maximum")
    field(EGU,  "ns")
    field(PREC, "6")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Min of the last measurement XMIN
record(ai, "OSC:LT10:20:GetMeasMin") {
    field(DESC, "Last measurement minimum")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readFloat(XMIN) OSC:LT10:20")
    field(LSV,  "MINOR")
    field(HSV,  "MINOR")
    field(EGU,  "s")
    field(PREC, "12")
    field(FLNK, "OSC:LT10:20:GetOffsetInvMeasMin")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calcout, "OSC:LT10:20:GetMeasMin_nscalc") {
	field( DESC, "Measured Min in ns" )
	field( INPA, "OSC:LT10:20:GetMeasMin CPP MS" )
	field( CALC, "A*1e9" )
	field( OUT,  "OSC:LT10:20:GetMeasMin_ns PP MS" )
}
record(ai, "OSC:LT10:20:GetMeasMin_ns") {
    field(DESC, "Last measurement minimum")
    field(EGU,  "ns")
    field(PREC, "6")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Value of display rel XREL
record(ai, "OSC:LT10:20:GetDispREL") {
    field(DESC, "Get display REL")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readFloat(XREL) OSC:LT10:20")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetDispREL") {
    field(DESC, "Set display REL")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeFloat(XREL) OSC:LT10:20")
    field(FLNK, "OSC:LT10:20:GetDispREL")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}


# DAC output mode of mean and jitter DACs ANMD
record(mbbi, "OSC:LT10:20:GetDACOutputMode") {
    field(DESC, "Get rear DAC output mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(ANMD) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(ZRST, "chart/chart")
    field(ONST, "DAC/chart")
    field(TWST, "chart/DAC")
    field(THST, "DAC/DAC")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV THSV")
}

record(mbbo, "OSC:LT10:20:SetDACOutputMode") {
    field(DESC, "Set rear DAC output mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(ANMD) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(ZRST, "chart/chart")
    field(ONST, "DAC/chart")
    field(TWST, "chart/DAC")
    field(THST, "DAC/DAC")
    field(FLNK, "OSC:LT10:20:GetDACOutputMode")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV THSV")
}

# Start position of internal delay scan DBEG
record(ai, "OSC:LT10:20:GetDelayStartPos") {
    field(DESC, "Get int. delay start pos.")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(DBEG) OSC:LT10:20")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetDelayStartPos") {
    field(DESC, "Set int. delay start pos.")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(DBEG) OSC:LT10:20")
    field(DRVH, "50000")
    field(DRVL, "1")
    field(FLNK, "OSC:LT10:20:GetDelayStartPos")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Internal delay scan mode DSEN
record(mbbi, "OSC:LT10:20:GetDelayScanMode") {
    field(DESC, "Get internal delay mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(DSEN) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "DELAY OFF")
    field(ONST, "DELAY HOLD")
    field(TWST, "DELAY SCAN")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV")
}

record(mbbo, "OSC:LT10:20:SetDelayScanMode") {
    field(DESC, "Set internal delay mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(DSEN) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "DELAY OFF")
    field(ONST, "DELAY HOLD")
    field(TWST, "DELAY SCAN")
    field(FLNK, "OSC:LT10:20:GetDelayScanMode")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV")
}

# Internal delay scan step size DSTP
# "The range of sizes that may be set is between 1us and 10ms in a 1,2,5 seq"
record(ai, "OSC:LT10:20:GetDelayScanStepSize") {
    field(DESC, "Get int delay scan step size")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readFloat(DSTP) OSC:LT10:20")
    field(EGU,  "s")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetDelayScanStepSize") {
    field(DESC, "Set int delay scan step size")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeFloat(DSTP) OSC:LT10:20")
    field(DRVH, "0.01")
    field(DRVL, "0.000001")
    field(EGU,  "s")
    field(FLNK, "OSC:LT10:20:GetDelayScanStepSize")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Hold time between scan points when in scan mode HOLD
# "from .01s to 1000s in .01s steps"
record(ai, "OSC:LT10:20:GetScanHoldTime") {
    field(DESC, "Get hold time btn scan pts")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readFloat(HOLD) OSC:LT10:20")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetScanHoldTime") {
    field(DESC, "Set hold time btn scan pts")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeFloat(HOLD) OSC:LT10:20")
    field(DRVH, "1000")
    field(DRVL, "0.01")
    field(FLNK, "OSC:LT10:20:GetScanHoldTime")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Clear and start a scan SCAN
record(bo, "OSC:LT10:20:StartScan") {
    field(DESC, "Clear and start a scan")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(SCAN) OSC:LT10:20")
	info(autosaveFields, "ZSV OSV")
}

# Clear, but not start, a scan SCLR
record(bo, "OSC:LT10:20:ClearScan") {
    field(DESC, "Clear but not start a scan")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(SCLR) OSC:LT10:20")
	info(autosaveFields, "ZSV OSV")
}

# Enable/disable scanning SCEN
record(mbbi, "OSC:LT10:20:GetScanMode") {
    field(DESC, "Get scanning mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(SCEN) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "DISABLED")
    field(ONST, "SINGLE SCAN")
    field(TWST, "REPEAT SCAN")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV")
}

record(mbbo, "OSC:LT10:20:SetScanMode") {
    field(DESC, "Set scanning mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(SCEN) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "DISABLED")
    field(ONST, "SINGLE SCAN")
    field(TWST, "REPEAT SCAN")
    field(FLNK, "OSC:LT10:20:GetScanMode")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV")
}

# Number of the last completed scan point SLOC
record(ai, "OSC:LT10:20:GetLastScanPoint") {
    field(DESC, "Get # of last scan point")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(SLOC) OSC:LT10:20")
}

# Number of scan points SCPT
# Legal values are 2,5,10,25,50,125,250
record(mbbi, "OSC:LT10:20:GetNumScanPoints") {
    field(DESC, "Get # of scan points")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(SCPT) OSC:LT10:20")
    field(ZRVL, "2")
    field(ONVL, "5")
    field(TWVL, "10")
    field(THVL, "25")
    field(FRVL, "50")
    field(FVVL, "125")
    field(SXVL, "250")
    field(ZRST, "2")
    field(ONST, "5")
    field(TWST, "10")
    field(THST, "25")
    field(FRST, "50")
    field(FVST, "125")
    field(SXST, "250")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV THSV FRSV FVSV SXSV")
}

record(mbbo, "OSC:LT10:20:SetNumScanPoints") {
    field(DESC, "Set # of scan points")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(SCPT) OSC:LT10:20")
    field(ZRVL, "2")
    field(ONVL, "5")
    field(TWVL, "10")
    field(THVL, "25")
    field(FRVL, "50")
    field(FVVL, "125")
    field(SXVL, "250")
    field(ZRST, "2")
    field(ONST, "5")
    field(TWST, "10")
    field(THST, "25")
    field(FRST, "50")
    field(FVST, "125")
    field(SXST, "250")
    field(FLNK, "OSC:LT10:20:GetNumScanPoints")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV THSV FRSV FVSV SXSV")
}

# DAC output scan starting voltage VBEG
record(ai, "OSC:LT10:20:DAC0:GetScanStartV") {
    field(DESC, "Get DAC0 out scan starting V")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(VBEG,0) OSC:LT10:20")
    field(PREC, "2")
    field(EGU,  "V")
	info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ai, "OSC:LT10:20:DAC1:GetScanStartV") {
    field(DESC, "Get DAC1 out scan starting V")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(VBEG,1) OSC:LT10:20")
    field(PREC, "2")
    field(EGU,  "V")
	info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ao, "OSC:LT10:20:DAC0:SetScanStartV") {
    field(DESC, "Set DAC0 out scan starting V")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanFloat(VBEG,0) OSC:LT10:20")
    field(DRVH, "10")
    field(DRVL, "-10")
    field(PREC, "2")
    field(EGU,  "V")
    field(FLNK, "OSC:LT10:20:DAC0:GetScanStartV")
	info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ao, "OSC:LT10:20:DAC1:SetScanStartV") {
    field(DESC, "Set DAC1 out scan starting V")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanFloat(VBEG,1) OSC:LT10:20")
    field(DRVH, "10")
    field(DRVL, "-10")
    field(PREC, "2")
    field(EGU,  "V")
    field(FLNK, "OSC:LT10:20:DAC1:GetScanStartV")
	info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

# Current DAC output voltage VOUT
record(ai, "OSC:LT10:20:DAC0:GetOutputV") {
    field(DESC, "Get DAC0 current output V")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(VOUT,0) OSC:LT10:20")
    field(PREC, "2")
    field(EGU,  "V")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ai, "OSC:LT10:20:DAC1:GetOutputV") {
    field(DESC, "Get DAC1 current output V")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(VOUT,1) OSC:LT10:20")
    field(PREC, "2")
    field(EGU,  "V")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# DAC scan step size [V] VSTP
record(ai, "OSC:LT10:20:DAC0:GetScanStepSize") {
    field(DESC, "Get DAC0 scan step size [V]")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(VSTP,0) OSC:LT10:20")
    field(PREC, "2")
    field(EGU,  "V")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ai, "OSC:LT10:20:DAC1:GetScanStepSize") {
    field(DESC, "Get DAC1 scan step size [V]")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(VSTP,1) OSC:LT10:20")
    field(PREC, "2")
    field(EGU,  "V")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:DAC0:SetScanStepSize") {
    field(DESC, "Set DAC0 scan step size [V]")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db readChanFloat(VSTP,0) OSC:LT10:20")
    field(PREC, "2")
    field(EGU,  "V")
    field(FLNK, "OSC:LT10:20:DAC0:GetScanStepSize")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:DAC1:SetScanStepSize") {
    field(DESC, "Set DAC1 scan step size [V]")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db readChanFloat(VSTP,1) OSC:LT10:20")
    field(PREC, "2")
    field(EGU,  "V")
    field(FLNK, "OSC:LT10:20:DAC1:GetScanStepSize")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}


# Autoprint mode AUTP
record(bi, "OSC:LT10:20:GetAutoprintMode") {
    field(DESC, "Get autoprint mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(AUTP) OSC:LT10:20")
    field(ZNAM, "OFF")
    field(ONAM, "ON")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SetAutoprintMode") {
    field(DESC, "Set autoprint mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(AUTP) OSC:LT10:20")
    field(ZNAM, "OFF")
    field(ONAM, "ON")
    field(FLNK, "OSC:LT10:20:GetAutoprintMode")
	info(autosaveFields, "VAL ZSV OSV")
}

# Autoscale the displayed graph AUTS
record(bo, "OSC:LT10:20:AutoscaleGraph") {
    field(DESC, "Autoscale displayed graph")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(AUTS) OSC:LT10:20")
}

# Cursor position CURS
# Excluded from periodic UpdateAll
record(ai, "OSC:LT10:20:GetCursorPosition") {
    field(DESC, "Get current cursor position")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(CURS) OSC:LT10:20")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetCursorPosition") {
    field(DESC, "Set current cursor position")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(CURS) OSC:LT10:20")
    field(DRVH, "250")
    field(DRVL, "1")
    field(FLNK, "OSC:LT10:20:GetCursorPosition")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Displayed graph type DGPH
record(mbbi, "OSC:LT10:20:GetDisplayGraphType") {
    field(DESC, "Get displayed graph type")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(DGPH) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "HISTOGRAM")
    field(ONST, "MEAN")
    field(TWST, "JITTER")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV")
}

record(mbbo, "OSC:LT10:20:SetDisplayGraphType") {
    field(DESC, "Set displayed graph type")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(DGPH) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "HISTOGRAM")
    field(ONST, "MEAN")
    field(TWST, "JITTER")
    field(FLNK, "OSC:LT10:20:GetDisplayGraphType")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV")
}

# Clear the displayed graph GCLR
record(bo, "OSC:LT10:20:ClearDisplayGraph") {
    field(DESC, "Clear the displayed graph")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(GCLR) OSC:LT10:20")
}

# Enable/disable graphs GENA
record(bi, "OSC:LT10:20:GetGraphEnable") {
    field(DESC, "Get graph enable status")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(GENA) OSC:LT10:20")
    field(ZNAM, "OFF")
    field(ONAM, "ON")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SetGraphEnable") {
    field(DESC, "Set graph enable status")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(GENA) OSC:LT10:20")
    field(ZNAM, "OFF")
    field(ONAM, "ON")
    field(FLNK, "OSC:LT10:20:GetGraphEnable")
	info(autosaveFields, "VAL ZSV OSV")
}

# Graph scale settings GSCL
# One record per setting, even though they all use the same 4-letter command
record(ai, "OSC:LT10:20:GetGraphScaleHistV") {
    field(DESC, "Get histogram vertical scale")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(GSCL,0) OSC:LT10:20")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ai, "OSC:LT10:20:GetGraphScaleHistH") {
    field(DESC, "Get histogram horiz scale")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(GSCL,1) OSC:LT10:20")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ai, "OSC:LT10:20:GetGraphScaleHistB") {
    field(DESC, "Get histogram # bins")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(GSCL,2) OSC:LT10:20")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ai, "OSC:LT10:20:GetGraphScaleMean") {
    field(DESC, "Get mean graph scale")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(GSCL,3) OSC:LT10:20")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ai, "OSC:LT10:20:GetGraphScaleJitter") {
    field(DESC, "Get jitter graph scale")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(GSCL,4) OSC:LT10:20")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetGraphScaleHistV") {
    field(DESC, "Set histogram vertical scale")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanFloat(GSCL,0) OSC:LT10:20")
    field(FLNK, "OSC:LT10:20:GetGraphScaleHistV")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetGraphScaleHistH") {
    field(DESC, "Set histogram horiz scale")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanFloat(GSCL,1) OSC:LT10:20")
    field(FLNK, "OSC:LT10:20:GetGraphScaleHistH")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetGraphScaleHistB") {
    field(DESC, "Set histogram # bins")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanFloat(GSCL,2) OSC:LT10:20")
    field(FLNK, "OSC:LT10:20:GetGraphScaleHistB")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetGraphScaleMean") {
    field(DESC, "Set mean graph scale")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanFloat(GSCL,3) OSC:LT10:20")
    field(FLNK, "OSC:LT10:20:GetGraphScaleMean")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetGraphScaleJitter") {
    field(DESC, "Set jitter graph scale")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanFloat(GSCL,4) OSC:LT10:20")
    field(FLNK, "OSC:LT10:20:GetGraphScaleJitter")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Output device PDEV
record(bi, "OSC:LT10:20:GetPrintingDevice") {
    field(DESC, "Get current printing device")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(PDEV) OSC:LT10:20")
    field(ZNAM, "PRINTER")
    field(ONAM, "PLOTTER")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SetPrintingDevice") {
    field(DESC, "Set current printing device")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(PDEV) OSC:LT10:20")
    field(ZNAM, "PRINTER")
    field(ONAM, "PLOTTER")
    field(FLNK, "OSC:LT10:20:GetPrintingDevice")
	info(autosaveFields, "VAL ZSV OSV")
}

# Plotter GPIB address PLAD
record(ai, "OSC:LT10:20:GetPlotterAddress") {
    field(DESC, "Get plotter GPIB address")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(PLAD) OSC:LT10:20")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:SetPlotterAddress") {
    field(DESC, "Set plotter GPIB address")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(PLAD) OSC:LT10:20")
    field(DRVH, "30")
    field(DRVL, "1")
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Plotter port setting PLPT
record(bi, "OSC:LT10:20:GetPlotterPort") {
    field(DESC, "Get plotter port RS232/GPIB")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(PLPT) OSC:LT10:20")
    field(ZNAM, "RS-232")
    field(ONAM, "GPIB")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SetPlotterPort") {
    field(DESC, "Set plotter port RS232/GPIB")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(PLPT) OSC:LT10:20")
    field(ZNAM, "RS-232")
    field(ONAM, "GPIB")
    field(FLNK, "OSC:LT10:20:GetPlotterPort")
	info(autosaveFields, "VAL ZSV OSV")
}

# Initiate a plot or print PLOT
record(bo, "OSC:LT10:20:StartPlot") {
    field(DESC, "Initiate a plot/print")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(PLOT) OSC:LT10:20")
}

# Clear any plots or prints in progress PCLR
record(bo, "OSC:LT10:20:ClearPlot") {
    field(DESC, "Clear any plots/prints")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(PCLR) OSC:LT10:20")
}

# Display source setting DISP
record(mbbi, "OSC:LT10:20:GetDisplaySource") {
    field(DESC, "Get current display source")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(DISP) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(FRVL, "4")
    field(FVVL, "5")
    field(SXVL, "6")
    field(ZRST, "MEAN VALUE")
    field(ONST, "REL VALUE")
    field(TWST, "JITTER")
    field(THST, "MAX VALUE")
    field(FRST, "MIN VALUE")
    field(FVST, "TRIG THRESH")
    field(SXST, "DVM INPUTS")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV THSV FRSV FVSV SXSV")
}

record(mbbo, "OSC:LT10:20:SetDisplaySource") {
    field(DESC, "Set display source")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(DISP) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(THVL, "3")
    field(FRVL, "4")
    field(FVVL, "5")
    field(SXVL, "6")
    field(ZRST, "MEAN VALUE")
    field(ONST, "REL VALUE")
    field(TWST, "JITTER")
    field(THST, "MAX VALUE")
    field(FRST, "MIN VALUE")
    field(FVST, "TRIG THRESH")
    field(SXST, "DVM INPUTS")
    field(FLNK, "OSC:LT10:20:GetDisplaySource")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV THSV FRSV FVSV SXSV")
}

# Set the x1000 expand mode in freq/per modes EXPD
record(bi, "OSC:LT10:20:GetExpandMode") {
    field(DESC, "Get x1000 expand mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(EXPD) OSC:LT10:20")
    field(ZNAM, "OFF")
    field(ONAM, "ON")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SetExpandMode") {
    field(DESC, "Set x1000 expand mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(EXPD) OSC:LT10:20")
    field(ZNAM, "OFF")
    field(ONAM, "ON")
    field(FLNK, "OSC:LT10:20:GetExpandMode")
	info(autosaveFields, "VAL ZSV OSV")
}

# Keypress simulation KEYS
# Only specific keycodes are permitted. See manual.
record(ai, "OSC:LT10:20:GetLastKeyPressed") {
    field(DESC, "Get last key pressed")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(KEYS) OSC:LT10:20")
}

record(ao, "OSC:LT10:20:SendKeyPress") {
    field(DESC, "Send key press (keycode)")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(KEYS) OSC:LT10:20")
    field(FLNK, "OSC:LT10:20:GetLastKeyPressed")
}

# Clock source setting CLCK
record(bi, "OSC:LT10:20:GetClockSource") {
    field(DESC, "Get current clock source")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(CLCK) OSC:LT10:20")
    field(ZNAM, "INTERNAL")
    field(ONAM, "EXTERNAL")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SetClockSource") {
    field(DESC, "Set current clock source")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(CLCK) OSC:LT10:20")
    field(ZNAM, "INTERNAL")
    field(ONAM, "EXTERNAL")
    field(FLNK, "OSC:LT10:20:GetClockSource")
	info(autosaveFields, "VAL ZSV OSV")
}

# External clock frequency setting CLKF
record(bi, "OSC:LT10:20:GetClockFreq") {
    field(DESC, "Get external clock freq")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(CLKF) OSC:LT10:20")
    field(ZNAM, "10 MHz")
    field(ONAM, "5 MHz")
	info(autosaveFields, "ZSV OSV")
}

record(bo, "OSC:LT10:20:SetClockFreq") {
    field(DESC, "Set external clock freq")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(CLKF) OSC:LT10:20")
    field(ZNAM, "10 MHz")
    field(ONAM, "5 MHz")
    field(FLNK, "OSC:LT10:20:GetClockFreq")
	info(autosaveFields, "VAL ZSV OSV")
}

# Binary I/O port read/write PORT
# No readback and not keyed to periodic update
record(ai, "OSC:LT10:20:GetPortByte") {
    field(DESC, "Get byte from bin I/O")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(PORT) OSC:LT10:20")
}

record(ao, "OSC:LT10:20:SetPortByte") {
    field(DESC, "Send byte to bin I/O")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(PORT) OSC:LT10:20")
    field(DRVH, "255")
    field(DRVL, "0")
}

# Printer port mode PRTM
record(mbbi, "OSC:LT10:20:GetPrinterPortMode") {
    field(DESC, "Get current printer pt mode")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(PRTM) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "PRINT")
    field(ONST, "INPUT")
    field(TWST, "OUTPUT")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV")
}

record(mbbo, "OSC:LT10:20:SetPrinterPortMode") {
    field(DESC, "Set current printer pt mode")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeInt(PRTM) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "PRINT")
    field(ONST, "INPUT")
    field(TWST, "OUTPUT")
    field(FLNK, "OSC:LT10:20:GetPrinterPortMode")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV")
}

# DVM input full scale volage RNGE
record(mbbi, "OSC:LT10:20:DVM0:GetVRange") {
    field(DESC, "Get DVM0 full voltage range")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(RNGE,0) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "autorange")
    field(ONST, "+-20 V")
    field(TWST, "+-2 V")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV")
}

record(mbbi, "OSC:LT10:20:DVM1:GetVRange") {
    field(DESC, "Get DVM1 full voltage range")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanInt(RNGE,1) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "autorange")
    field(ONST, "+-20 V")
    field(TWST, "+-2 V")
	info(autosaveFields, "UNSV COSV ZRSV ONSV TWSV")
}

record(mbbo, "OSC:LT10:20:DVM0:SetVRange") {
    field(DESC, "Set DVM0 full voltage range")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(RNGE,0) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "autorange")
    field(ONST, "+-20 V")
    field(TWST, "+-2 V")
    field(FLNK, "OSC:LT10:20:DVM0:GetVRange")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV")
}

record(mbbo, "OSC:LT10:20:DVM1:SetVRange") {
    field(DESC, "Set DVM1 full voltage range")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeChanInt(RNGE,1) OSC:LT10:20")
    field(ZRVL, "0")
    field(ONVL, "1")
    field(TWVL, "2")
    field(ZRST, "autorange")
    field(ONST, "+-20 V")
    field(TWST, "+-2 V")
    field(FLNK, "OSC:LT10:20:DVM1:GetVRange")
	info(autosaveFields, "VAL UNSV COSV ZRSV ONSV TWSV")
}

# Read voltage from DVM channels VOLT
record(ai, "OSC:LT10:20:DVM0:GetV") {
    field(DESC, "Get DVM0 voltage reading")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(VOLT,0) OSC:LT10:20")
    field(EGU,  "V")
    field(PREC, "3")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ai, "OSC:LT10:20:DVM1:GetV") {
    field(DESC, "Get DVM1 voltage reading")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readChanFloat(VOLT,1) OSC:LT10:20")
    field(EGU,  "V")
    field(PREC, "3")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Operation complete query *OPC
# Not included in periodic UpdateAll
record(bi, "OSC:LT10:20:GetOpComplete") {
    field(DESC, "Get op complete status")
    field(DTYP, "stream")
    field(INP,  "@sr620.proto.db readInt(*OPC) OSC:LT10:20")
    field(ZNAM, "IN PROGRESS")
    field(ONAM, "COMPLETE")
# Warning: Disabled for now as it does not reply
# till all measurements are complete.
# If not in auto-measurement, subsequent commands
# see replies separated by semi-colons, not CR
#    field(SCAN, ".5 second")
}

# Autocalibration procedure *CAL
# This takes very long (minutes), so no readback in this record
record(bo, "OSC:LT10:20:StartAutocal") {
    field(DESC, "Start autocal sequence")
    field(DTYP, "stream")
    field(OUT,  "@sr620.proto.db writeCmd(*CAL?) OSC:LT10:20")
}

# Measurement Offset Support
# This allows for setting an arbitrary offset that is added to the
# readback measurement values min, max, and mean.
record(ai, "OSC:LT10:20:MeasOffset") {
    field(DESC, "Measurement offset")
    field(DTYP, "Soft Channel")
    field(FLNK, "OSC:LT10:20:MeasOffsetUpdateFanout")
    field(PINI, "YES")
    info(autosaveFields, "VAL HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(fanout, "OSC:LT10:20:MeasOffsetUpdateFanout") {
    field(DESC, "MeasOffset update fanout")
    field(LNK1, "OSC:LT10:20:GetOffsetInvMeasMean")
    field(LNK2, "OSC:LT10:20:GetOffsetInvMeasMax")
    field(LNK3, "OSC:LT10:20:GetOffsetInvMeasMin")
}

record(calc, "OSC:LT10:20:GetOffsetInvMeasMean") {
    field(DESC, "Last meas. mean + offset")
    field(INPA, "OSC:LT10:20:GetMeasMean NPP")
    field(INPB, "OSC:LT10:20:MeasOffset")
    field(CALC, "-A+B")
    field(HSV,  "MINOR")
    field(LSV,  "MINOR")
    info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calcout, "OSC:LT10:20:GetOffsetInvMeasMean_nscalc") {
	field( DESC, "Measured mean in ns" )
	field( INPA, "OSC:LT10:20:GetOffsetInvMeasMean CPP MS" )
	field( CALC, "A*1e9" )
	field( OUT,  "OSC:LT10:20:GetOffsetInvMeasMean_ns PP MS" )
}
record(ai, "OSC:LT10:20:GetOffsetInvMeasMean_ns") {
    field(DESC, "Last measurement mean")
    field(EGU,  "ns")
    field(PREC, "6")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calc, "OSC:LT10:20:GetOffsetInvMeasMax") {
    field(DESC, "Last meas. max + offset")
    field(INPA, "OSC:LT10:20:GetMeasMax NPP")
    field(INPB, "OSC:LT10:20:MeasOffset")
    field(CALC, "-A+B")
    field(HSV,  "MINOR")
    field(LSV,  "MINOR")
    info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calcout, "OSC:LT10:20:GetOffsetInvMeasMax_nscalc") {
	field( DESC, "Measured Max in ns" )
	field( INPA, "OSC:LT10:20:GetOffsetInvMeasMax CPP MS" )
	field( CALC, "A*1e9" )
	field( OUT,  "OSC:LT10:20:GetOffsetInvMeasMax_ns PP MS" )
}
record(ai, "OSC:LT10:20:GetOffsetInvMeasMax_ns") {
    field(DESC, "Last measurement Max")
    field(EGU,  "ns")
    field(PREC, "6")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calc, "OSC:LT10:20:GetOffsetInvMeasMin") {
    field(DESC, "Last meas. min + offset")
    field(INPA, "OSC:LT10:20:GetMeasMin NPP")
    field(INPB, "OSC:LT10:20:MeasOffset")
    field(CALC, "-A+B")
    field(HSV,  "MINOR")
    field(LSV,  "MINOR")
    info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calcout, "OSC:LT10:20:GetOffsetInvMeasMin_nscalc") {
	field( DESC, "Measured Min in ns" )
	field( INPA, "OSC:LT10:20:GetOffsetInvMeasMin CPP MS" )
	field( CALC, "A*1e9" )
	field( OUT,  "OSC:LT10:20:GetOffsetInvMeasMin_ns PP MS" )
}
record(ai, "OSC:LT10:20:GetOffsetInvMeasMin_ns") {
    field(DESC, "Last measurement Min")
    field(EGU,  "ns")
    field(PREC, "6")
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(bi, "OSC:LT10:20:DispOffsetInvMeas") {
    field(DESC, "Display off/inv meas.")
    field(ONAM, "INV/OFFSET")
    field(ZNAM, "RAW MEAS.")
    field(PINI, "YES")
    info(autosaveFields, "VAL ZSV OSV")
}
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_CUR_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_CUR_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_CUR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:FREQ_CUR_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_CUR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_CUR_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_CUR_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_CUR_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_CUR_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_CUR_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_CUR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_1MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_CUR_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_CUR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_CUR_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_CUR_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_CUR_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_CUR_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_CUR_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_CUR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_6MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_CUR_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_CUR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_CUR_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_CUR_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_CUR_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_CUR_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_CUR_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_CUR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_30MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_CUR_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_CUR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_CUR_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_CUR_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_CUR_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_CUR_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_CUR_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_CUR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_1HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_CUR_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_CUR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_CUR_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_CUR_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_CUR_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_CUR_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_CUR_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_CUR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_6HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_CUR_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_CUR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_CUR_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_CUR_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_CUR_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_CUR_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_CUR_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_CUR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_24HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_CUR_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_CUR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_CUR_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_CUR_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_CUR_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_CUR_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_CUR_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_CUR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_3DAY PP" )

}

record( waveform, "OSC:LT10:20:FREQ_CUR_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_CUR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_CUR_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_CUR_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_CUR_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_CUR_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_CUR_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_CUR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_WEEK PP" )

}

record( waveform, "OSC:LT10:20:FREQ_CUR_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_CUR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_CUR_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_CUR_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_CUR_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_CUR_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_CUR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_CUR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_CUR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_CUR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_CUR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_CUR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_CUR_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_CUR_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_CUR_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_CUR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_CUR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_CUR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_CUR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_CUR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_CUR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_CUR_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_CUR_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_CUR_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_CUR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_CUR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_CUR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_CUR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_CUR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_CUR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_CUR_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_CUR_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_CUR_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_CUR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_CUR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_CUR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_CUR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_CUR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_CUR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_CUR_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_CUR_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_CUR_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_CUR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_CUR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_CUR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_CUR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_CUR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_CUR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_CUR_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_CUR_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_CUR_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_CUR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_CUR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_CUR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_CUR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_CUR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_CUR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_CUR_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_CUR_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_CUR_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_CUR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_CUR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_CUR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_CUR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_CUR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_CUR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_CUR_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_CUR_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_CUR_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_CUR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_CUR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_CUR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_CUR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_CUR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_CUR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_CUR_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_CUR_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_CUR_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_CUR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_CUR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_CUR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_CUR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_CUR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_CUR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_CUR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_CUR_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_CUR_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_CUR_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:FREQ_CUR_LAST_N_AVG",    "OSC:LT10:20:FREQ_CUR_AVG" )
alias( "OSC:LT10:20:FREQ_CUR_LAST_N_MAX",    "OSC:LT10:20:FREQ_CUR_MAX" )
alias( "OSC:LT10:20:FREQ_CUR_LAST_N_MIN",    "OSC:LT10:20:FREQ_CUR_MIN" )
alias( "OSC:LT10:20:FREQ_CUR_LAST_N_RMS",    "OSC:LT10:20:FREQ_CUR_RMS" )
alias( "OSC:LT10:20:FREQ_CUR_LAST_N_STD",    "OSC:LT10:20:FREQ_CUR_STD" )
alias( "OSC:LT10:20:FREQ_CUR_LAST_N_SLOPE",  "OSC:LT10:20:FREQ_CUR_SLOPE" )
alias( "OSC:LT10:20:FREQ_CUR_LAST_N_OFFSET", "OSC:LT10:20:FREQ_CUR_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_1MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_6MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_30MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_1HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_6HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_24HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_3DAY PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_WEEK PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:FREQ_ERR_LAST_N_AVG",    "OSC:LT10:20:FREQ_ERR_AVG" )
alias( "OSC:LT10:20:FREQ_ERR_LAST_N_MAX",    "OSC:LT10:20:FREQ_ERR_MAX" )
alias( "OSC:LT10:20:FREQ_ERR_LAST_N_MIN",    "OSC:LT10:20:FREQ_ERR_MIN" )
alias( "OSC:LT10:20:FREQ_ERR_LAST_N_RMS",    "OSC:LT10:20:FREQ_ERR_RMS" )
alias( "OSC:LT10:20:FREQ_ERR_LAST_N_STD",    "OSC:LT10:20:FREQ_ERR_STD" )
alias( "OSC:LT10:20:FREQ_ERR_LAST_N_SLOPE",  "OSC:LT10:20:FREQ_ERR_SLOPE" )
alias( "OSC:LT10:20:FREQ_ERR_LAST_N_OFFSET", "OSC:LT10:20:FREQ_ERR_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR_SMOOTHED.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR_SMOOTHED.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR_SMOOTHED.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR_SMOOTHED.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR_SMOOTHED.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR_SMOOTHED.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR_SMOOTHED.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR_SMOOTHED.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK PP" )

}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "Hz" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_ERR_SMOOTHED.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "Hz/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "Hz" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_AVG",    "OSC:LT10:20:FREQ_ERR_SMOOTHED_AVG" )
alias( "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_MAX",    "OSC:LT10:20:FREQ_ERR_SMOOTHED_MAX" )
alias( "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_MIN",    "OSC:LT10:20:FREQ_ERR_SMOOTHED_MIN" )
alias( "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_RMS",    "OSC:LT10:20:FREQ_ERR_SMOOTHED_RMS" )
alias( "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_STD",    "OSC:LT10:20:FREQ_ERR_SMOOTHED_STD" )
alias( "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_SLOPE",  "OSC:LT10:20:FREQ_ERR_SMOOTHED_SLOPE" )
alias( "OSC:LT10:20:FREQ_ERR_SMOOTHED_LAST_N_OFFSET", "OSC:LT10:20:FREQ_ERR_SMOOTHED_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_POS_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_POS_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_POS_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_POS_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_POS_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_POS_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_POS_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_POS_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_1HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_POS_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_POS_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_POS_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_6HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_POS_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_POS_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_POS_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_24HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_POS_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_POS_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_POS_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_POS_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_POS_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_POS_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_POS_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_AVG",    "OSC:LT10:20:FREQ_MOTOR_POS_AVG" )
alias( "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_MAX",    "OSC:LT10:20:FREQ_MOTOR_POS_MAX" )
alias( "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_MIN",    "OSC:LT10:20:FREQ_MOTOR_POS_MIN" )
alias( "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_RMS",    "OSC:LT10:20:FREQ_MOTOR_POS_RMS" )
alias( "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_STD",    "OSC:LT10:20:FREQ_MOTOR_POS_STD" )
alias( "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_SLOPE",  "OSC:LT10:20:FREQ_MOTOR_POS_SLOPE" )
alias( "OSC:LT10:20:FREQ_MOTOR_POS_LAST_N_OFFSET", "OSC:LT10:20:FREQ_MOTOR_POS_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_TGT_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_TGT_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_TGT_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_TGT_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_TGT_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_TGT_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_TGT_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_TGT_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_TGT_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_TGT_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FREQ_MOTOR_TGT_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK PP" )

}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FREQ_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FREQ_MOTOR_TGT_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_AVG",    "OSC:LT10:20:FREQ_MOTOR_TGT_AVG" )
alias( "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_MAX",    "OSC:LT10:20:FREQ_MOTOR_TGT_MAX" )
alias( "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_MIN",    "OSC:LT10:20:FREQ_MOTOR_TGT_MIN" )
alias( "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_RMS",    "OSC:LT10:20:FREQ_MOTOR_TGT_RMS" )
alias( "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_STD",    "OSC:LT10:20:FREQ_MOTOR_TGT_STD" )
alias( "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_SLOPE",  "OSC:LT10:20:FREQ_MOTOR_TGT_SLOPE" )
alias( "OSC:LT10:20:FREQ_MOTOR_TGT_LAST_N_OFFSET", "OSC:LT10:20:FREQ_MOTOR_TGT_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PHASE_MOTOR_POS_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PHASE_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PHASE_MOTOR_POS_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PHASE_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PHASE_MOTOR_POS_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PHASE_MOTOR_POS_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PHASE_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PHASE_MOTOR_POS_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PHASE_MOTOR_POS_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PHASE_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PHASE_MOTOR_POS_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PHASE_MOTOR_POS_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_1HR PP" )

}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PHASE_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PHASE_MOTOR_POS_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PHASE_MOTOR_POS_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PHASE_MOTOR_POS_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_6HR PP" )

}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PHASE_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PHASE_MOTOR_POS_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PHASE_MOTOR_POS_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PHASE_MOTOR_POS_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_24HR PP" )

}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PHASE_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PHASE_MOTOR_POS_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PHASE_MOTOR_POS_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PHASE_MOTOR_POS_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PHASE_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PHASE_MOTOR_POS_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PHASE_MOTOR_POS_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PHASE_MOTOR_POS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PHASE_MOTOR_POS_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_AVG",    "OSC:LT10:20:PHASE_MOTOR_POS_AVG" )
alias( "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_MAX",    "OSC:LT10:20:PHASE_MOTOR_POS_MAX" )
alias( "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_MIN",    "OSC:LT10:20:PHASE_MOTOR_POS_MIN" )
alias( "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_RMS",    "OSC:LT10:20:PHASE_MOTOR_POS_RMS" )
alias( "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_STD",    "OSC:LT10:20:PHASE_MOTOR_POS_STD" )
alias( "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_SLOPE",  "OSC:LT10:20:PHASE_MOTOR_POS_SLOPE" )
alias( "OSC:LT10:20:PHASE_MOTOR_POS_LAST_N_OFFSET", "OSC:LT10:20:PHASE_MOTOR_POS_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_MOTOR_TGT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_MOTOR_TGT_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_AVG",    "OSC:LT10:20:PID_COARSE_MOTOR_TGT_AVG" )
alias( "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_MAX",    "OSC:LT10:20:PID_COARSE_MOTOR_TGT_MAX" )
alias( "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_MIN",    "OSC:LT10:20:PID_COARSE_MOTOR_TGT_MIN" )
alias( "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_RMS",    "OSC:LT10:20:PID_COARSE_MOTOR_TGT_RMS" )
alias( "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_STD",    "OSC:LT10:20:PID_COARSE_MOTOR_TGT_STD" )
alias( "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_SLOPE",  "OSC:LT10:20:PID_COARSE_MOTOR_TGT_SLOPE" )
alias( "OSC:LT10:20:PID_COARSE_MOTOR_TGT_LAST_N_OFFSET", "OSC:LT10:20:PID_COARSE_MOTOR_TGT_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "mm" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "mm/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "mm" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_AVG",    "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_AVG" )
alias( "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_MAX",    "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_MAX" )
alias( "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_MIN",    "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_MIN" )
alias( "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_RMS",    "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_RMS" )
alias( "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_STD",    "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_STD" )
alias( "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_SLOPE",  "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_SLOPE" )
alias( "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_LAST_N_OFFSET", "OSC:LT10:20:PID_COARSE_WRITE_MOTOR_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_D_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_D_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_D CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_D_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_D.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_D_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_D_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_D_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_D_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_D_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_D CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_D_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_D.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_D_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_D_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_D_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_D_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_D_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_D CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_D_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_D.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_D_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_D_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_D_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_D_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_D_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_D CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_D_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_D.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_D_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_D_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_D_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_D_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_D_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_D CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_1HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_D_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_D.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_D_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_D_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_D_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_D_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_D_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_D CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_6HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_D_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_D.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_D_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_D_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_D_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_D_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_D_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_D CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_24HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_D_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_D.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_D_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_D_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_D_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_D_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_D_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_D CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_D_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_D.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_D_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_D_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_D_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_D_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_D_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_D CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_D_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_D.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_D_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_D_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_D_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_D_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_D_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_D_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_D_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_D_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_D_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_D_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_D_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_D_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_D_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_D_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_D_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_D_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_D_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_D_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_D_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_D_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_D_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_D_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_D_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_D_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_D_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_D_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_D_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_D_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_D_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_D_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_D_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_D_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_D_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_D_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_D_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_D_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_D_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_D_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_D_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_D_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_D_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_D_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_D_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_D_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_D_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_D_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_D_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_D_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_D_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_D_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_D_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_D_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_D_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_D_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_D_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_D_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_D_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_D_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_D_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_D_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_D_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_D_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_D_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_D_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_D_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_D_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_D_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_D_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_D_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_D_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_D_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_D_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_D_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_D_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_D_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_D_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_D_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_D_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_D_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_D_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_D_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PID_COARSE_D_LAST_N_AVG",    "OSC:LT10:20:PID_COARSE_D_AVG" )
alias( "OSC:LT10:20:PID_COARSE_D_LAST_N_MAX",    "OSC:LT10:20:PID_COARSE_D_MAX" )
alias( "OSC:LT10:20:PID_COARSE_D_LAST_N_MIN",    "OSC:LT10:20:PID_COARSE_D_MIN" )
alias( "OSC:LT10:20:PID_COARSE_D_LAST_N_RMS",    "OSC:LT10:20:PID_COARSE_D_RMS" )
alias( "OSC:LT10:20:PID_COARSE_D_LAST_N_STD",    "OSC:LT10:20:PID_COARSE_D_STD" )
alias( "OSC:LT10:20:PID_COARSE_D_LAST_N_SLOPE",  "OSC:LT10:20:PID_COARSE_D_SLOPE" )
alias( "OSC:LT10:20:PID_COARSE_D_LAST_N_OFFSET", "OSC:LT10:20:PID_COARSE_D_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_ERR_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_ERR_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_ERR_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_ERR_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_ERR_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_ERR_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_ERR_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_ERR_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_ERR_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_ERR_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_ERR_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_ERR_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_ERR_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_1HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_ERR_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_ERR_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_ERR_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_6HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_ERR_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_ERR_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_ERR_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_24HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_ERR_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_ERR_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_ERR_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_ERR_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_ERR_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_ERR_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_ERR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_ERR_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_ERR_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_ERR_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_ERR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_ERR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_ERR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_ERR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_ERR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_ERR_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_ERR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_ERR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_ERR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_ERR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_ERR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_ERR_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_ERR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_ERR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_ERR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_ERR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_ERR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_ERR_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_ERR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_ERR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_ERR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_ERR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_ERR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_ERR_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_ERR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_ERR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_ERR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_ERR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_ERR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_ERR_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_ERR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_ERR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_ERR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_ERR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_ERR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_ERR_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_ERR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_ERR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_ERR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_ERR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_ERR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_ERR_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_ERR_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_ERR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_ERR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_ERR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_ERR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_ERR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_ERR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_ERR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_ERR_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PID_COARSE_ERR_LAST_N_AVG",    "OSC:LT10:20:PID_COARSE_ERR_AVG" )
alias( "OSC:LT10:20:PID_COARSE_ERR_LAST_N_MAX",    "OSC:LT10:20:PID_COARSE_ERR_MAX" )
alias( "OSC:LT10:20:PID_COARSE_ERR_LAST_N_MIN",    "OSC:LT10:20:PID_COARSE_ERR_MIN" )
alias( "OSC:LT10:20:PID_COARSE_ERR_LAST_N_RMS",    "OSC:LT10:20:PID_COARSE_ERR_RMS" )
alias( "OSC:LT10:20:PID_COARSE_ERR_LAST_N_STD",    "OSC:LT10:20:PID_COARSE_ERR_STD" )
alias( "OSC:LT10:20:PID_COARSE_ERR_LAST_N_SLOPE",  "OSC:LT10:20:PID_COARSE_ERR_SLOPE" )
alias( "OSC:LT10:20:PID_COARSE_ERR_LAST_N_OFFSET", "OSC:LT10:20:PID_COARSE_ERR_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_I_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_I_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_I CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_I_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_I.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_I_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_I_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_I_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_I_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_I_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_I CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_I_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_I.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_I_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_I_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_I_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_I_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_I_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_I CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_I_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_I.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_I_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_I_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_I_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_I_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_I_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_I CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_I_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_I.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_I_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_I_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_I_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_I_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_I_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_I CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_1HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_I_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_I.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_I_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_I_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_I_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_I_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_I_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_I CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_6HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_I_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_I.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_I_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_I_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_I_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_I_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_I_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_I CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_24HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_I_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_I.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_I_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_I_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_I_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_I_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_I_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_I CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_I_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_I.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_I_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_I_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_I_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_I_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_I_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_I CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_I_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_I.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_I_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_I_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_I_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_I_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_I_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_I_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_I_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_I_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_I_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_I_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_I_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_I_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_I_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_I_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_I_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_I_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_I_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_I_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_I_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_I_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_I_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_I_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_I_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_I_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_I_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_I_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_I_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_I_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_I_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_I_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_I_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_I_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_I_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_I_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_I_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_I_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_I_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_I_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_I_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_I_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_I_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_I_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_I_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_I_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_I_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_I_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_I_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_I_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_I_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_I_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_I_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_I_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_I_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_I_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_I_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_I_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_I_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_I_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_I_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_I_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_I_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_I_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_I_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_I_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_I_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_I_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_I_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_I_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_I_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_I_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_I_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_I_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_I_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_I_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_I_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_I_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_I_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_I_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_I_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_I_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_I_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PID_COARSE_I_LAST_N_AVG",    "OSC:LT10:20:PID_COARSE_I_AVG" )
alias( "OSC:LT10:20:PID_COARSE_I_LAST_N_MAX",    "OSC:LT10:20:PID_COARSE_I_MAX" )
alias( "OSC:LT10:20:PID_COARSE_I_LAST_N_MIN",    "OSC:LT10:20:PID_COARSE_I_MIN" )
alias( "OSC:LT10:20:PID_COARSE_I_LAST_N_RMS",    "OSC:LT10:20:PID_COARSE_I_RMS" )
alias( "OSC:LT10:20:PID_COARSE_I_LAST_N_STD",    "OSC:LT10:20:PID_COARSE_I_STD" )
alias( "OSC:LT10:20:PID_COARSE_I_LAST_N_SLOPE",  "OSC:LT10:20:PID_COARSE_I_SLOPE" )
alias( "OSC:LT10:20:PID_COARSE_I_LAST_N_OFFSET", "OSC:LT10:20:PID_COARSE_I_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_OUTPUT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_OUTPUT_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_OUTPUT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_OUTPUT_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_OUTPUT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_OUTPUT_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_OUTPUT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_OUTPUT_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_OUTPUT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_OUTPUT_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_OUTPUT_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_OUTPUT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_OUTPUT_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_OUTPUT_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_OUTPUT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_OUTPUT_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_OUTPUT_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_OUTPUT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_OUTPUT_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_OUTPUT.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_OUTPUT_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_AVG",    "OSC:LT10:20:PID_COARSE_OUTPUT_AVG" )
alias( "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_MAX",    "OSC:LT10:20:PID_COARSE_OUTPUT_MAX" )
alias( "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_MIN",    "OSC:LT10:20:PID_COARSE_OUTPUT_MIN" )
alias( "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_RMS",    "OSC:LT10:20:PID_COARSE_OUTPUT_RMS" )
alias( "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_STD",    "OSC:LT10:20:PID_COARSE_OUTPUT_STD" )
alias( "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_SLOPE",  "OSC:LT10:20:PID_COARSE_OUTPUT_SLOPE" )
alias( "OSC:LT10:20:PID_COARSE_OUTPUT_LAST_N_OFFSET", "OSC:LT10:20:PID_COARSE_OUTPUT_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_P_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_P_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_P CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_P_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_P.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_P_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_P_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_P_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_P_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_P_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_P CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_P_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_P.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_P_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_P_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_P_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_P_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_P_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_P CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_P_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_P.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_P_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_P_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_P_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_P_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_P_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_P CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_P_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_P.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_P_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_P_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_P_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_P_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_P_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_P CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_1HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_P_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_P.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_P_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_P_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_P_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_P_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_P_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_P CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_6HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_P_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_P.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_P_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_P_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_P_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_P_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_P_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_P CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_24HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_P_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_P.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_P_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_P_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_P_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_P_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_P_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_P CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_P_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_P.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_P_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_P_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_P_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_P_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_P_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_P CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_P_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_P.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_P_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_P_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_P_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_P_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_P_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_P_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_P_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_P_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_P_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_P_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_P_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_P_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_P_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_P_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_P_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_P_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_P_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_P_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_P_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_P_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_P_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_P_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_P_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_P_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_P_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_P_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_P_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_P_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_P_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_P_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_P_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_P_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_P_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_P_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_P_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_P_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_P_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_P_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_P_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_P_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_P_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_P_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_P_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_P_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_P_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_P_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_P_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_P_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_P_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_P_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_P_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_P_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_P_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_P_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_P_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_P_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_P_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_P_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_P_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_P_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_P_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_P_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_P_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_P_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_P_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_P_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_P_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_P_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_P_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_P_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_P_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_P_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_P_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_P_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_P_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_P_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_P_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_P_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_P_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_P_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_P_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_P_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PID_COARSE_P_LAST_N_AVG",    "OSC:LT10:20:PID_COARSE_P_AVG" )
alias( "OSC:LT10:20:PID_COARSE_P_LAST_N_MAX",    "OSC:LT10:20:PID_COARSE_P_MAX" )
alias( "OSC:LT10:20:PID_COARSE_P_LAST_N_MIN",    "OSC:LT10:20:PID_COARSE_P_MIN" )
alias( "OSC:LT10:20:PID_COARSE_P_LAST_N_RMS",    "OSC:LT10:20:PID_COARSE_P_RMS" )
alias( "OSC:LT10:20:PID_COARSE_P_LAST_N_STD",    "OSC:LT10:20:PID_COARSE_P_STD" )
alias( "OSC:LT10:20:PID_COARSE_P_LAST_N_SLOPE",  "OSC:LT10:20:PID_COARSE_P_SLOPE" )
alias( "OSC:LT10:20:PID_COARSE_P_LAST_N_OFFSET", "OSC:LT10:20:PID_COARSE_P_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_TARGET_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_TARGET.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_TARGET_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_TARGET_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_TARGET.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_TARGET_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_TARGET_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_TARGET_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_TARGET.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_TARGET_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_TARGET_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_TARGET_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_TARGET.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_TARGET_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_TARGET_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_TARGET_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_1HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_TARGET.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_TARGET_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_TARGET_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_TARGET_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_6HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_TARGET.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_TARGET_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_TARGET_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_TARGET_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_24HR PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_TARGET.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_TARGET_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_TARGET_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_TARGET_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_TARGET.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_TARGET_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_TARGET_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PID_COARSE_TARGET_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "rad" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PID_COARSE_TARGET.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PID_COARSE_TARGET_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PID_COARSE_TARGET_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PID_COARSE_TARGET_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_TARGET_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_TARGET_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_TARGET_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_TARGET_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_TARGET_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_TARGET_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_TARGET_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_TARGET_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_TARGET_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_TARGET_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_TARGET_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_TARGET_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_TARGET_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_TARGET_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_TARGET_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_TARGET_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_TARGET_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_TARGET_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PID_COARSE_TARGET_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "rad/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_TARGET_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "rad" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_AVG",    "OSC:LT10:20:PID_COARSE_TARGET_AVG" )
alias( "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_MAX",    "OSC:LT10:20:PID_COARSE_TARGET_MAX" )
alias( "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_MIN",    "OSC:LT10:20:PID_COARSE_TARGET_MIN" )
alias( "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_RMS",    "OSC:LT10:20:PID_COARSE_TARGET_RMS" )
alias( "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_STD",    "OSC:LT10:20:PID_COARSE_TARGET_STD" )
alias( "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_SLOPE",  "OSC:LT10:20:PID_COARSE_TARGET_SLOPE" )
alias( "OSC:LT10:20:PID_COARSE_TARGET_LAST_N_OFFSET", "OSC:LT10:20:PID_COARSE_TARGET_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_IN_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_IN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_IN_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_IN_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_IN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_IN_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_IN_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_IN_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_IN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_IN_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_IN_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_IN_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_IN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_IN_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_IN_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_IN_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_1HR PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_IN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_IN_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_IN_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_IN_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_6HR PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_IN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_IN_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_IN_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_IN_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_24HR PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_IN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_IN_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_IN_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_IN_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_IN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_IN_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_IN_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_IN_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_IN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_IN_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_IN_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_IN_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_IN_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_IN_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_IN_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_IN_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_IN_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_IN_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_IN_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_IN_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_IN_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_IN_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_IN_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_IN_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_IN_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_IN_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_IN_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_IN_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_IN_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_IN_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_IN_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_AVG",    "OSC:LT10:20:PIEZO_AMP_IN_AVG" )
alias( "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_MAX",    "OSC:LT10:20:PIEZO_AMP_IN_MAX" )
alias( "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_MIN",    "OSC:LT10:20:PIEZO_AMP_IN_MIN" )
alias( "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_RMS",    "OSC:LT10:20:PIEZO_AMP_IN_RMS" )
alias( "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_STD",    "OSC:LT10:20:PIEZO_AMP_IN_STD" )
alias( "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_SLOPE",  "OSC:LT10:20:PIEZO_AMP_IN_SLOPE" )
alias( "OSC:LT10:20:PIEZO_AMP_IN_LAST_N_OFFSET", "OSC:LT10:20:PIEZO_AMP_IN_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_MON_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_MON.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_MON_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_MON_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_1MIN PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_MON.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_MON_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_MON_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_MON_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_6MIN PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_MON.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_MON_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_MON_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_MON_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_30MIN PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_MON.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_MON_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_MON_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_MON_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_1HR PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_MON.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_MON_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_MON_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_MON_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_6HR PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_MON.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_MON_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_MON_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_MON_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_24HR PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_MON.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_MON_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_MON_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_MON_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_3DAY PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_MON.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_MON_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_MON_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:PIEZO_AMP_MON_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_WEEK PP" )

}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:PIEZO_AMP_MON.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:PIEZO_AMP_MON_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:PIEZO_AMP_MON_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:PIEZO_AMP_MON_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_MON_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_MON_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_MON_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_MON_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_MON_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_MON_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_MON_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_MON_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_MON_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_MON_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_MON_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_MON_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_MON_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_MON_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_MON_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_MON_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_MON_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_MON_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:PIEZO_AMP_MON_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_MON_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_AVG",    "OSC:LT10:20:PIEZO_AMP_MON_AVG" )
alias( "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_MAX",    "OSC:LT10:20:PIEZO_AMP_MON_MAX" )
alias( "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_MIN",    "OSC:LT10:20:PIEZO_AMP_MON_MIN" )
alias( "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_RMS",    "OSC:LT10:20:PIEZO_AMP_MON_RMS" )
alias( "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_STD",    "OSC:LT10:20:PIEZO_AMP_MON_STD" )
alias( "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_SLOPE",  "OSC:LT10:20:PIEZO_AMP_MON_SLOPE" )
alias( "OSC:LT10:20:PIEZO_AMP_MON_LAST_N_OFFSET", "OSC:LT10:20:PIEZO_AMP_MON_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_CTR_TIME_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_CTR_TIME_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_CTR_TIME.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_CTR_TIME_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_CTR_TIME_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_CTR_TIME_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_CTR_TIME_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_1MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_CTR_TIME.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_CTR_TIME_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_CTR_TIME_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_CTR_TIME_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_CTR_TIME_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_6MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_CTR_TIME.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_CTR_TIME_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_CTR_TIME_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_CTR_TIME_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_CTR_TIME_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_30MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_CTR_TIME.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_CTR_TIME_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_CTR_TIME_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_CTR_TIME_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_CTR_TIME_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_1HR PP" )

}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_CTR_TIME.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_CTR_TIME_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_CTR_TIME_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_CTR_TIME_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_CTR_TIME_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_6HR PP" )

}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_CTR_TIME.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_CTR_TIME_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_CTR_TIME_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_CTR_TIME_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_CTR_TIME_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_24HR PP" )

}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_CTR_TIME.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_CTR_TIME_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_CTR_TIME_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_CTR_TIME_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_CTR_TIME_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_3DAY PP" )

}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_CTR_TIME.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_CTR_TIME_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_CTR_TIME_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_CTR_TIME_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_CTR_TIME_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_WEEK PP" )

}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_CTR_TIME.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_CTR_TIME_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_CTR_TIME_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_CTR_TIME_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_CTR_TIME_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_CTR_TIME_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_CTR_TIME_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_CTR_TIME_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_CTR_TIME_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_CTR_TIME_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_CTR_TIME_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_CTR_TIME_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_CTR_TIME_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_CTR_TIME_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_CTR_TIME_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_CTR_TIME_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_CTR_TIME_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_CTR_TIME_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_CTR_TIME_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_CTR_TIME_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_CTR_TIME_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_CTR_TIME_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_CTR_TIME_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_CTR_TIME_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_CTR_TIME_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_CTR_TIME_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_CTR_TIME_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_CTR_TIME_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_CTR_TIME_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_CTR_TIME_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_CTR_TIME_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_CTR_TIME_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_CTR_TIME_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_CTR_TIME_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_CTR_TIME_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_CTR_TIME_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_CTR_TIME_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_CTR_TIME_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_CTR_TIME_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_CTR_TIME_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_CTR_TIME_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_CTR_TIME_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_CTR_TIME_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_CTR_TIME_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_CTR_TIME_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_CTR_TIME_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_CTR_TIME_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_CTR_TIME_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_CTR_TIME_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_CTR_TIME_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_CTR_TIME_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_CTR_TIME_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_CTR_TIME_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_CTR_TIME_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_CTR_TIME_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_CTR_TIME_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_CTR_TIME_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_CTR_TIME_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_CTR_TIME_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_CTR_TIME_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_CTR_TIME_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_CTR_TIME_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_CTR_TIME_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_CTR_TIME_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_CTR_TIME_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_CTR_TIME_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_CTR_TIME_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_CTR_TIME_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_CTR_TIME_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_CTR_TIME_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:FS_CTR_TIME_LAST_N_AVG",    "OSC:LT10:20:FS_CTR_TIME_AVG" )
alias( "OSC:LT10:20:FS_CTR_TIME_LAST_N_MAX",    "OSC:LT10:20:FS_CTR_TIME_MAX" )
alias( "OSC:LT10:20:FS_CTR_TIME_LAST_N_MIN",    "OSC:LT10:20:FS_CTR_TIME_MIN" )
alias( "OSC:LT10:20:FS_CTR_TIME_LAST_N_RMS",    "OSC:LT10:20:FS_CTR_TIME_RMS" )
alias( "OSC:LT10:20:FS_CTR_TIME_LAST_N_STD",    "OSC:LT10:20:FS_CTR_TIME_STD" )
alias( "OSC:LT10:20:FS_CTR_TIME_LAST_N_SLOPE",  "OSC:LT10:20:FS_CTR_TIME_SLOPE" )
alias( "OSC:LT10:20:FS_CTR_TIME_LAST_N_OFFSET", "OSC:LT10:20:FS_CTR_TIME_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIMING_ERROR_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIMING_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIMING_ERROR_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIMING_ERROR_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_1MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIMING_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIMING_ERROR_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIMING_ERROR_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIMING_ERROR_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_6MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIMING_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIMING_ERROR_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIMING_ERROR_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIMING_ERROR_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_30MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIMING_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIMING_ERROR_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIMING_ERROR_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIMING_ERROR_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_1HR PP" )

}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIMING_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIMING_ERROR_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIMING_ERROR_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIMING_ERROR_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_6HR PP" )

}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIMING_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIMING_ERROR_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIMING_ERROR_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIMING_ERROR_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_24HR PP" )

}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIMING_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIMING_ERROR_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIMING_ERROR_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIMING_ERROR_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_3DAY PP" )

}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIMING_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIMING_ERROR_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIMING_ERROR_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIMING_ERROR_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_WEEK PP" )

}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIMING_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIMING_ERROR_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIMING_ERROR_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIMING_ERROR_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIMING_ERROR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIMING_ERROR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIMING_ERROR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIMING_ERROR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIMING_ERROR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIMING_ERROR_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIMING_ERROR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIMING_ERROR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIMING_ERROR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIMING_ERROR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIMING_ERROR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIMING_ERROR_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIMING_ERROR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIMING_ERROR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIMING_ERROR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIMING_ERROR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIMING_ERROR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIMING_ERROR_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIMING_ERROR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIMING_ERROR_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_AVG",    "OSC:LT10:20:FS_TIMING_ERROR_AVG" )
alias( "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_MAX",    "OSC:LT10:20:FS_TIMING_ERROR_MAX" )
alias( "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_MIN",    "OSC:LT10:20:FS_TIMING_ERROR_MIN" )
alias( "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_RMS",    "OSC:LT10:20:FS_TIMING_ERROR_RMS" )
alias( "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_STD",    "OSC:LT10:20:FS_TIMING_ERROR_STD" )
alias( "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_SLOPE",  "OSC:LT10:20:FS_TIMING_ERROR_SLOPE" )
alias( "OSC:LT10:20:FS_TIMING_ERROR_LAST_N_OFFSET", "OSC:LT10:20:FS_TIMING_ERROR_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_BUCKET_ERROR_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "buckets" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_BUCKET_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_BUCKET_ERROR_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "buckets" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_BUCKET_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_BUCKET_ERROR_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_BUCKET_ERROR_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "buckets" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_BUCKET_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_BUCKET_ERROR_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_BUCKET_ERROR_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "buckets" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_BUCKET_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_BUCKET_ERROR_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_BUCKET_ERROR_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_1HR PP" )

}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "buckets" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_BUCKET_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_BUCKET_ERROR_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_BUCKET_ERROR_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_BUCKET_ERROR_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_6HR PP" )

}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "buckets" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_BUCKET_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_BUCKET_ERROR_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_BUCKET_ERROR_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_BUCKET_ERROR_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_24HR PP" )

}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "buckets" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_BUCKET_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_BUCKET_ERROR_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_BUCKET_ERROR_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_BUCKET_ERROR_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY PP" )

}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "buckets" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_BUCKET_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_BUCKET_ERROR_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_BUCKET_ERROR_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK PP" )

}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "buckets" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_BUCKET_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_BUCKET_ERROR_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "buckets/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "buckets/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "buckets/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "buckets/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "buckets/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "buckets/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "buckets/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "buckets/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "buckets/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_BUCKET_ERROR_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "buckets" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_AVG",    "OSC:LT10:20:FS_BUCKET_ERROR_AVG" )
alias( "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_MAX",    "OSC:LT10:20:FS_BUCKET_ERROR_MAX" )
alias( "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_MIN",    "OSC:LT10:20:FS_BUCKET_ERROR_MIN" )
alias( "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_RMS",    "OSC:LT10:20:FS_BUCKET_ERROR_RMS" )
alias( "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_STD",    "OSC:LT10:20:FS_BUCKET_ERROR_STD" )
alias( "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_SLOPE",  "OSC:LT10:20:FS_BUCKET_ERROR_SLOPE" )
alias( "OSC:LT10:20:FS_BUCKET_ERROR_LAST_N_OFFSET", "OSC:LT10:20:FS_BUCKET_ERROR_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_UNFIXED_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_UNFIXED_ERROR_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_UNFIXED_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_UNFIXED_ERROR_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_UNFIXED_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_UNFIXED_ERROR_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_UNFIXED_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_UNFIXED_ERROR_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR PP" )

}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_UNFIXED_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_UNFIXED_ERROR_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_UNFIXED_ERROR_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR PP" )

}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_UNFIXED_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_UNFIXED_ERROR_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_UNFIXED_ERROR_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR PP" )

}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_UNFIXED_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_UNFIXED_ERROR_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_UNFIXED_ERROR_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY PP" )

}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_UNFIXED_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_UNFIXED_ERROR_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK PP" )

}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ps" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_UNFIXED_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ps/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_UNFIXED_ERROR_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ps" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_AVG",    "OSC:LT10:20:FS_UNFIXED_ERROR_AVG" )
alias( "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_MAX",    "OSC:LT10:20:FS_UNFIXED_ERROR_MAX" )
alias( "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_MIN",    "OSC:LT10:20:FS_UNFIXED_ERROR_MIN" )
alias( "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_RMS",    "OSC:LT10:20:FS_UNFIXED_ERROR_RMS" )
alias( "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_STD",    "OSC:LT10:20:FS_UNFIXED_ERROR_STD" )
alias( "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_SLOPE",  "OSC:LT10:20:FS_UNFIXED_ERROR_SLOPE" )
alias( "OSC:LT10:20:FS_UNFIXED_ERROR_LAST_N_OFFSET", "OSC:LT10:20:FS_UNFIXED_ERROR_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIC_ERROR_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ticks" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIC_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIC_ERROR_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIC_ERROR_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIC_ERROR_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_1MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ticks" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIC_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIC_ERROR_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIC_ERROR_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIC_ERROR_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_6MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ticks" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIC_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIC_ERROR_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIC_ERROR_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIC_ERROR_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_30MIN PP" )

}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ticks" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIC_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIC_ERROR_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIC_ERROR_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIC_ERROR_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_1HR PP" )

}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ticks" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIC_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIC_ERROR_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIC_ERROR_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIC_ERROR_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_6HR PP" )

}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ticks" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIC_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIC_ERROR_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIC_ERROR_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIC_ERROR_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_24HR PP" )

}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ticks" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIC_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIC_ERROR_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIC_ERROR_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIC_ERROR_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_3DAY PP" )

}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ticks" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIC_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIC_ERROR_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIC_ERROR_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:FS_TIC_ERROR_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_WEEK PP" )

}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ticks" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:FS_TIC_ERROR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:FS_TIC_ERROR_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:FS_TIC_ERROR_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:FS_TIC_ERROR_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ticks/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIC_ERROR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIC_ERROR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIC_ERROR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIC_ERROR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIC_ERROR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIC_ERROR_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ticks/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIC_ERROR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIC_ERROR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIC_ERROR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIC_ERROR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIC_ERROR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIC_ERROR_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ticks/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIC_ERROR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIC_ERROR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIC_ERROR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIC_ERROR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIC_ERROR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIC_ERROR_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ticks/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIC_ERROR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIC_ERROR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIC_ERROR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIC_ERROR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIC_ERROR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIC_ERROR_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ticks/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIC_ERROR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIC_ERROR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIC_ERROR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIC_ERROR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIC_ERROR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIC_ERROR_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ticks/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIC_ERROR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIC_ERROR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIC_ERROR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIC_ERROR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIC_ERROR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIC_ERROR_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ticks/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIC_ERROR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIC_ERROR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIC_ERROR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIC_ERROR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIC_ERROR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIC_ERROR_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ticks/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:FS_TIC_ERROR_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:FS_TIC_ERROR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:FS_TIC_ERROR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:FS_TIC_ERROR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:FS_TIC_ERROR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:FS_TIC_ERROR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:FS_TIC_ERROR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:FS_TIC_ERROR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:FS_TIC_ERROR_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ticks/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:FS_TIC_ERROR_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ticks" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:FS_TIC_ERROR_LAST_N_AVG",    "OSC:LT10:20:FS_TIC_ERROR_AVG" )
alias( "OSC:LT10:20:FS_TIC_ERROR_LAST_N_MAX",    "OSC:LT10:20:FS_TIC_ERROR_MAX" )
alias( "OSC:LT10:20:FS_TIC_ERROR_LAST_N_MIN",    "OSC:LT10:20:FS_TIC_ERROR_MIN" )
alias( "OSC:LT10:20:FS_TIC_ERROR_LAST_N_RMS",    "OSC:LT10:20:FS_TIC_ERROR_RMS" )
alias( "OSC:LT10:20:FS_TIC_ERROR_LAST_N_STD",    "OSC:LT10:20:FS_TIC_ERROR_STD" )
alias( "OSC:LT10:20:FS_TIC_ERROR_LAST_N_SLOPE",  "OSC:LT10:20:FS_TIC_ERROR_SLOPE" )
alias( "OSC:LT10:20:FS_TIC_ERROR_LAST_N_OFFSET", "OSC:LT10:20:FS_TIC_ERROR_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "s" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_1MIN PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "s" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_6MIN PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "s" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_30MIN PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "s" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_1HR PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "s" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_6HR PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "s" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_24HR PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "s" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_3DAY PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "s" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_WEEK PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "s" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "s" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "s/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "s" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "s/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "s" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "s/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "s" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "s/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "s" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "s/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "s" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "s/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "s" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "s/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "s" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "s/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "s" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "s/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:GetMeasMean_LAST_N_AVG",    "OSC:LT10:20:GetMeasMean_AVG" )
alias( "OSC:LT10:20:GetMeasMean_LAST_N_MAX",    "OSC:LT10:20:GetMeasMean_MAX" )
alias( "OSC:LT10:20:GetMeasMean_LAST_N_MIN",    "OSC:LT10:20:GetMeasMean_MIN" )
alias( "OSC:LT10:20:GetMeasMean_LAST_N_RMS",    "OSC:LT10:20:GetMeasMean_RMS" )
alias( "OSC:LT10:20:GetMeasMean_LAST_N_STD",    "OSC:LT10:20:GetMeasMean_STD" )
alias( "OSC:LT10:20:GetMeasMean_LAST_N_SLOPE",  "OSC:LT10:20:GetMeasMean_SLOPE" )
alias( "OSC:LT10:20:GetMeasMean_LAST_N_OFFSET", "OSC:LT10:20:GetMeasMean_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_ns_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_ns_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean_ns.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_ns_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_ns_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_ns_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_ns_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_1MIN PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean_ns.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_ns_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_ns_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_ns_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_ns_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_6MIN PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean_ns.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_ns_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_ns_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_ns_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_ns_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_30MIN PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean_ns.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_ns_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_ns_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_ns_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_ns_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_1HR PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean_ns.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_ns_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_ns_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_ns_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_ns_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_6HR PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean_ns.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_ns_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_ns_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_ns_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_ns_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_24HR PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean_ns.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_ns_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_ns_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_ns_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_ns_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_3DAY PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean_ns.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_ns_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_ns_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:GetMeasMean_ns_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:GetMeasMean_ns_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_WEEK PP" )

}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "ns" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:GetMeasMean_ns.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:GetMeasMean_ns_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:GetMeasMean_ns_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:GetMeasMean_ns_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_ns_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_ns_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_ns_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_ns_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_ns_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_ns_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_ns_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_ns_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_ns_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_ns_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_ns_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_ns_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_ns_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_ns_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_ns_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_ns_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_ns_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_ns_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_ns_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_ns_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_ns_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_ns_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_ns_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_ns_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_ns_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_ns_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_ns_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_ns_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_ns_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_ns_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_ns_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_ns_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_ns_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_ns_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_ns_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_ns_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_ns_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_ns_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_ns_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_ns_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_ns_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_ns_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_ns_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_ns_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_ns_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_ns_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_ns_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_ns_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_ns_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_ns_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_ns_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_ns_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_ns_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_ns_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_ns_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_ns_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:GetMeasMean_ns_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:GetMeasMean_ns_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:GetMeasMean_ns_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:GetMeasMean_ns_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:GetMeasMean_ns_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:GetMeasMean_ns_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:GetMeasMean_ns_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:GetMeasMean_ns_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:GetMeasMean_ns_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "ns/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:GetMeasMean_ns_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "ns" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:GetMeasMean_ns_LAST_N_AVG",    "OSC:LT10:20:GetMeasMean_ns_AVG" )
alias( "OSC:LT10:20:GetMeasMean_ns_LAST_N_MAX",    "OSC:LT10:20:GetMeasMean_ns_MAX" )
alias( "OSC:LT10:20:GetMeasMean_ns_LAST_N_MIN",    "OSC:LT10:20:GetMeasMean_ns_MIN" )
alias( "OSC:LT10:20:GetMeasMean_ns_LAST_N_RMS",    "OSC:LT10:20:GetMeasMean_ns_RMS" )
alias( "OSC:LT10:20:GetMeasMean_ns_LAST_N_STD",    "OSC:LT10:20:GetMeasMean_ns_STD" )
alias( "OSC:LT10:20:GetMeasMean_ns_LAST_N_SLOPE",  "OSC:LT10:20:GetMeasMean_ns_SLOPE" )
alias( "OSC:LT10:20:GetMeasMean_ns_LAST_N_OFFSET", "OSC:LT10:20:GetMeasMean_ns_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_DIODE_PWR_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_DIODE_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_DIODE_PWR_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_DIODE_PWR_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_1MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_DIODE_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_DIODE_PWR_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_DIODE_PWR_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_DIODE_PWR_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_6MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_DIODE_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_DIODE_PWR_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_DIODE_PWR_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_DIODE_PWR_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_30MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_DIODE_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_DIODE_PWR_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_DIODE_PWR_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_DIODE_PWR_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_1HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_DIODE_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_DIODE_PWR_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_DIODE_PWR_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_DIODE_PWR_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_6HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_DIODE_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_DIODE_PWR_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_DIODE_PWR_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_DIODE_PWR_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_24HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_DIODE_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_DIODE_PWR_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_DIODE_PWR_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_DIODE_PWR_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_3DAY PP" )

}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_DIODE_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_DIODE_PWR_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_DIODE_PWR_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_DIODE_PWR_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_WEEK PP" )

}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_DIODE_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_DIODE_PWR_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_DIODE_PWR_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_DIODE_PWR_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_DIODE_PWR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_DIODE_PWR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_DIODE_PWR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_DIODE_PWR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_DIODE_PWR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_DIODE_PWR_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_DIODE_PWR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_DIODE_PWR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_DIODE_PWR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_DIODE_PWR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_DIODE_PWR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_DIODE_PWR_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_DIODE_PWR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_DIODE_PWR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_DIODE_PWR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_DIODE_PWR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_DIODE_PWR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_DIODE_PWR_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_DIODE_PWR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_DIODE_PWR_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_AVG",    "OSC:LT10:20:CH1_DIODE_PWR_AVG" )
alias( "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_MAX",    "OSC:LT10:20:CH1_DIODE_PWR_MAX" )
alias( "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_MIN",    "OSC:LT10:20:CH1_DIODE_PWR_MIN" )
alias( "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_RMS",    "OSC:LT10:20:CH1_DIODE_PWR_RMS" )
alias( "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_STD",    "OSC:LT10:20:CH1_DIODE_PWR_STD" )
alias( "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_SLOPE",  "OSC:LT10:20:CH1_DIODE_PWR_SLOPE" )
alias( "OSC:LT10:20:CH1_DIODE_PWR_LAST_N_OFFSET", "OSC:LT10:20:CH1_DIODE_PWR_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_FEEDBACK_GAIN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_FEEDBACK_GAIN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_FEEDBACK_GAIN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_FEEDBACK_GAIN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_FEEDBACK_GAIN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_FEEDBACK_GAIN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_FEEDBACK_GAIN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY PP" )

}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_FEEDBACK_GAIN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK PP" )

}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_FEEDBACK_GAIN.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_FEEDBACK_GAIN_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_AVG",    "OSC:LT10:20:CH1_FEEDBACK_GAIN_AVG" )
alias( "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_MAX",    "OSC:LT10:20:CH1_FEEDBACK_GAIN_MAX" )
alias( "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_MIN",    "OSC:LT10:20:CH1_FEEDBACK_GAIN_MIN" )
alias( "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_RMS",    "OSC:LT10:20:CH1_FEEDBACK_GAIN_RMS" )
alias( "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_STD",    "OSC:LT10:20:CH1_FEEDBACK_GAIN_STD" )
alias( "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_SLOPE",  "OSC:LT10:20:CH1_FEEDBACK_GAIN_SLOPE" )
alias( "OSC:LT10:20:CH1_FEEDBACK_GAIN_LAST_N_OFFSET", "OSC:LT10:20:CH1_FEEDBACK_GAIN_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_1MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_6MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_30MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_1HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_6HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_24HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_3DAY PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_WEEK PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:CH1_PHASE_LAST_N_AVG",    "OSC:LT10:20:CH1_PHASE_AVG" )
alias( "OSC:LT10:20:CH1_PHASE_LAST_N_MAX",    "OSC:LT10:20:CH1_PHASE_MAX" )
alias( "OSC:LT10:20:CH1_PHASE_LAST_N_MIN",    "OSC:LT10:20:CH1_PHASE_MIN" )
alias( "OSC:LT10:20:CH1_PHASE_LAST_N_RMS",    "OSC:LT10:20:CH1_PHASE_RMS" )
alias( "OSC:LT10:20:CH1_PHASE_LAST_N_STD",    "OSC:LT10:20:CH1_PHASE_STD" )
alias( "OSC:LT10:20:CH1_PHASE_LAST_N_SLOPE",  "OSC:LT10:20:CH1_PHASE_SLOPE" )
alias( "OSC:LT10:20:CH1_PHASE_LAST_N_OFFSET", "OSC:LT10:20:CH1_PHASE_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_X30_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30 CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE_X30.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_X30_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_X30_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_X30_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30 CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_1MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE_X30.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_X30_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_X30_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_X30_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30 CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_6MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE_X30.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_X30_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_X30_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_X30_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30 CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_30MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE_X30.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_X30_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_X30_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_X30_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30 CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_1HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE_X30.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_X30_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_X30_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_X30_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30 CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_6HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE_X30.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_X30_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_X30_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_X30_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30 CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_24HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE_X30.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_X30_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_X30_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_X30_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30 CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_3DAY PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE_X30.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_X30_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_X30_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_PHASE_X30_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30 CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_WEEK PP" )

}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_PHASE_X30.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_PHASE_X30_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_PHASE_X30_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_PHASE_X30_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_X30_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_X30_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_X30_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_X30_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_X30_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_X30_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_X30_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_X30_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_X30_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_X30_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_X30_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_X30_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_X30_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_X30_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_X30_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_X30_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_X30_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_X30_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_X30_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_X30_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_X30_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_X30_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_X30_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_X30_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_X30_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_X30_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_X30_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_X30_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_X30_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_X30_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_X30_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_X30_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_X30_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_X30_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_X30_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_X30_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_X30_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_X30_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_X30_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_X30_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_X30_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_X30_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_PHASE_X30_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_PHASE_X30_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_PHASE_X30_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_PHASE_X30_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_PHASE_X30_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_PHASE_X30_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_PHASE_X30_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_PHASE_X30_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:CH1_PHASE_X30_LAST_N_AVG",    "OSC:LT10:20:CH1_PHASE_X30_AVG" )
alias( "OSC:LT10:20:CH1_PHASE_X30_LAST_N_MAX",    "OSC:LT10:20:CH1_PHASE_X30_MAX" )
alias( "OSC:LT10:20:CH1_PHASE_X30_LAST_N_MIN",    "OSC:LT10:20:CH1_PHASE_X30_MIN" )
alias( "OSC:LT10:20:CH1_PHASE_X30_LAST_N_RMS",    "OSC:LT10:20:CH1_PHASE_X30_RMS" )
alias( "OSC:LT10:20:CH1_PHASE_X30_LAST_N_STD",    "OSC:LT10:20:CH1_PHASE_X30_STD" )
alias( "OSC:LT10:20:CH1_PHASE_X30_LAST_N_SLOPE",  "OSC:LT10:20:CH1_PHASE_X30_SLOPE" )
alias( "OSC:LT10:20:CH1_PHASE_X30_LAST_N_OFFSET", "OSC:LT10:20:CH1_PHASE_X30_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_RF_PWR_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_RF_PWR_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_RF_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_RF_PWR_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_RF_PWR_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_RF_PWR_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_RF_PWR_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_1MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_RF_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_RF_PWR_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_RF_PWR_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_RF_PWR_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_RF_PWR_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_6MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_RF_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_RF_PWR_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_RF_PWR_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_RF_PWR_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_RF_PWR_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_30MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_RF_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_RF_PWR_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_RF_PWR_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_RF_PWR_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_RF_PWR_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_1HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_RF_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_RF_PWR_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_RF_PWR_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_RF_PWR_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_RF_PWR_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_6HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_RF_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_RF_PWR_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_RF_PWR_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_RF_PWR_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_RF_PWR_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_24HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_RF_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_RF_PWR_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_RF_PWR_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_RF_PWR_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_RF_PWR_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_3DAY PP" )

}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_RF_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_RF_PWR_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_RF_PWR_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_RF_PWR_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_RF_PWR_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_WEEK PP" )

}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_RF_PWR.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_RF_PWR_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_RF_PWR_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_RF_PWR_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_RF_PWR_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_RF_PWR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_RF_PWR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_RF_PWR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_RF_PWR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_RF_PWR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_RF_PWR_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_RF_PWR_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_RF_PWR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_RF_PWR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_RF_PWR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_RF_PWR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_RF_PWR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_RF_PWR_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_RF_PWR_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_RF_PWR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_RF_PWR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_RF_PWR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_RF_PWR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_RF_PWR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_RF_PWR_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_RF_PWR_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_RF_PWR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_RF_PWR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_RF_PWR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_RF_PWR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_RF_PWR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_RF_PWR_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_RF_PWR_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_RF_PWR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_RF_PWR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_RF_PWR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_RF_PWR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_RF_PWR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_RF_PWR_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_RF_PWR_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_RF_PWR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_RF_PWR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_RF_PWR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_RF_PWR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_RF_PWR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_RF_PWR_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_RF_PWR_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_RF_PWR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_RF_PWR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_RF_PWR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_RF_PWR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_RF_PWR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_RF_PWR_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_RF_PWR_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_RF_PWR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_RF_PWR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_RF_PWR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_RF_PWR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_RF_PWR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_RF_PWR_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_RF_PWR_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_RF_PWR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_RF_PWR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_RF_PWR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_RF_PWR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_RF_PWR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_RF_PWR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_RF_PWR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_RF_PWR_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "V" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "V/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "V" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:CH1_RF_PWR_LAST_N_AVG",    "OSC:LT10:20:CH1_RF_PWR_AVG" )
alias( "OSC:LT10:20:CH1_RF_PWR_LAST_N_MAX",    "OSC:LT10:20:CH1_RF_PWR_MAX" )
alias( "OSC:LT10:20:CH1_RF_PWR_LAST_N_MIN",    "OSC:LT10:20:CH1_RF_PWR_MIN" )
alias( "OSC:LT10:20:CH1_RF_PWR_LAST_N_RMS",    "OSC:LT10:20:CH1_RF_PWR_RMS" )
alias( "OSC:LT10:20:CH1_RF_PWR_LAST_N_STD",    "OSC:LT10:20:CH1_RF_PWR_STD" )
alias( "OSC:LT10:20:CH1_RF_PWR_LAST_N_SLOPE",  "OSC:LT10:20:CH1_RF_PWR_SLOPE" )
alias( "OSC:LT10:20:CH1_RF_PWR_LAST_N_OFFSET", "OSC:LT10:20:CH1_RF_PWR_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_60 Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_LAST_60
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 60 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60 PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60" )
{
    field( DESC, "LAST_60 Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 60 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "60" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "60" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_LAST_60:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "60" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "60" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60 CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_1MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_6MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_30MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_1HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_6HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_24HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_3DAY PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_WEEK PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_AVG",    "OSC:LT10:20:CH1_CALC_PHASE_AVG" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_MAX",    "OSC:LT10:20:CH1_CALC_PHASE_MAX" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_MIN",    "OSC:LT10:20:CH1_CALC_PHASE_MIN" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_RMS",    "OSC:LT10:20:CH1_CALC_PHASE_RMS" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_STD",    "OSC:LT10:20:CH1_CALC_PHASE_STD" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_SLOPE",  "OSC:LT10:20:CH1_CALC_PHASE_SLOPE" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_LAST_N_OFFSET", "OSC:LT10:20:CH1_CALC_PHASE_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_RMS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_RMS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_RMS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_RMS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_RMS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_RMS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_RMS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_RMS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_RMS.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_RMS_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_AVG",    "OSC:LT10:20:CH1_CALC_PHASE_RMS_AVG" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_MAX",    "OSC:LT10:20:CH1_CALC_PHASE_RMS_MAX" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_MIN",    "OSC:LT10:20:CH1_CALC_PHASE_RMS_MIN" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_RMS",    "OSC:LT10:20:CH1_CALC_PHASE_RMS_RMS" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_STD",    "OSC:LT10:20:CH1_CALC_PHASE_RMS_STD" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_SLOPE",  "OSC:LT10:20:CH1_CALC_PHASE_RMS_SLOPE" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_RMS_LAST_N_OFFSET", "OSC:LT10:20:CH1_CALC_PHASE_RMS_OFFSET" )
#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "LAST_N Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "0" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N" )
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_STD.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "0" )
	field( INPC, "0" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "N" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "N" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "60" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN" )
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_STD.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "1" )
	field( INPC, "60" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "s" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "s" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "360" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN" )
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_STD.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "360" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "30MIN Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "1800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN" )
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_STD.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "1800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "1HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_STD_1HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "3600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR" )
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_STD.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "60" )
	field( INPC, "3600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "min" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "min" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "6HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_STD_6HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "21600" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR" )
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_STD.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "21600" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "24HR Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_STD_24HR
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "86400" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR" )
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_STD.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "86400" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "3DAY Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "259200" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY" )
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_STD.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "3600" )
	field( INPC, "259200" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "hr" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "hr" )
	field( PREC,  "3" )
}

#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		PUBLISH		- Publish period for updating output array, in seconds
#						If zero, publish on each update
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_EGU	- Conversion between seconds and X_EGU, e.g. 3600 for hrs
#		NAME		- Name of this time period
#		DESC		- Description of Time Period, default "WEEK Hist"
#		OUT			- Name of waveform PV where history is written
#						Defaults to OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK
#

# History asub
# Monitors an scalar value and records it's history
#	over the specified time period.
# The delay between samples is determined by the time
# period divided by the size of the output array.
#	Inputs:
#		A	- a single scalar value of type double
#		P	- double publish interval in seconds (Use 0 for update on change)
#		T	- double history interval in seconds (Use 0 for update on change)
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_SUB" )
{
	field( DESC, "Keeps History of PV" )
	field( SCAN, ".1 second" )
	field( PINI, "NO" )
	field( INAM, "History_Init" )
	field( SNAM, "History_Process" )
	field( EFLG, "ON CHANGE" )

	field( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD CP NMS" )

	field( FTP, "DOUBLE" )
	field( NOP, 1 )
	field( INPP, "0.1" )

	field( FTT, "DOUBLE" )
	field( NOT, 1 )
	field( INPT, "604800" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK PP" )

}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK" )
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "fs" )
	field( NELM, 300 )
	field( TSEL, "OSC:LT10:20:CH1_CALC_PHASE_STD.TIME" )
	info( autosaveFields, "VAL" )
}

# Create an array of time coordinates in the specified units
record( acalcout, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK:CALCX" ) 
{
	field( DESC, "x-axis times" )
	field( CALC, "(B>0)?(IX+1-A)*C/(A*B):(IX+1-A)" )
	field( INPA, "300" )
	field( INPB, "86400" )
	field( INPC, "604800" )
	field( NELM, "300" )
	field( PINI, "YES" )
	field( SCAN, "Passive" )
	field( EGU,  "days" )
	field( PREC, "3" )
	field( OUT,  "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK:X-AXIS PP" )
}

record( waveform, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK:X-AXIS" ) 
{
	field( DESC, "x-axis times" )
	field( SCAN, "Passive" )
	field( DTYP, "Soft Channel" )
	field( FTVL, "FLOAT" )
	field( NELM, "300" )
	field( EGU,  "days" )
	field( PREC,  "3" )
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_30MIN_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_1HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_6HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_24HR_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_3DAY_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# EPICS Template for waveform processing
#
# This template is used to process waveform records
# and write the results as new waveforms and scalar PV's
#
# Required Macro Definitions
# WAVE			- Waveform name, for example AMO_KB1_WAV_01
#
# Optional macros
# NELM          - Number of elements per history array (default 300)
# EGU			- Engineering units: fs, C, mm, etc. (default "")
# RMS_LOLO		- Low, low, limit (default "0")
# RMS_LOW		- Low limit (default "0")
# RMS_HIGH		- High limit (default "0")
# RMS_HIHI		- High, high, limit (default "0")

# RMS asub
# Processing this PV computes the RMS value for the input array
# generating FitTime and Charge PV's for each cavity
#
# Inputs
# INPA:	Waveform PV, Type DOUBLE, any length
#
# Outputs
# OUTA:	RMS    - ai PV - RMS over all samples
# OUTB:	MIN    - ai PV - Min of all samples
# OUTC:	MAX    - ai PV - Max of all samples
# OUTD:	AVG    - ai PV - Average sample value
# OUTE: STD    - ai PV - Std deviation 
# OUTF: SLOPE  - ai PV - Slope of linear least squares fit
# OUTG: OFFSET - ai PV - Offset of linear least squares fit
record( aSub, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_RMS_SUB" )
{
	field( DESC, "Calculate RMS for array" )
	field( SCAN, "Passive" )
	field( PINI, "NO" )
	field( INAM, "RMS_Init" )
	field( SNAM, "RMS_Process" )

	field( FTA,  "DOUBLE" )
	field( NOA,  "300" )
	field( INPA, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_OFFSET PP" )
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_MAX" )
{
	field( DESC, "MAX for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_AVG" )
{
	field( DESC, "AVG of waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_MIN" )
{
	field( DESC, "MIN for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_RMS" )
{
	field( DESC, "RMS for waveform" )
	field( LOLO, "0" )
	field( LOW,  "0"  )
	field( HIGH, "0" )
	field( HIHI, "0" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	field( LLSV,  "MAJOR" )
	field( LSV,   "MINOR" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_STD" )
{
	field( DESC, "StdDev for waveform" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_SLOPE" )
{
	field( DESC, "Best fit linear slope" )
	field( EGU,  "fs/s" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_CALC_PHASE_STD_WEEK_OFFSET" )
{
	field( DESC, "Offset of least squares fit" )
	field( EGU,  "fs" )
	field( PREC, "4" )
	info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In some screens, you want to say "display statistic X" without being too
# particular about the data set. Use these aliases to hide that part of the PV

alias( "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_AVG",    "OSC:LT10:20:CH1_CALC_PHASE_STD_AVG" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_MAX",    "OSC:LT10:20:CH1_CALC_PHASE_STD_MAX" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_MIN",    "OSC:LT10:20:CH1_CALC_PHASE_STD_MIN" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_RMS",    "OSC:LT10:20:CH1_CALC_PHASE_STD_RMS" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_STD",    "OSC:LT10:20:CH1_CALC_PHASE_STD_STD" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_SLOPE",  "OSC:LT10:20:CH1_CALC_PHASE_STD_SLOPE" )
alias( "OSC:LT10:20:CH1_CALC_PHASE_STD_LAST_N_OFFSET", "OSC:LT10:20:CH1_CALC_PHASE_STD_OFFSET" )
#
# Dedicated PV's for femtosecond controls
# Replaces matlab PVs:  SIOC:SYS0:ML01:AO480 to AO493
#

# SIOC:SYS0:ML01:AO480
# Watchdog counter, increments when the code is running, set to
# zero to kill the code. Locks against multiple copies
record( longout, "OSC:LT10:20:FS_WATCHDOG" )
{
	field( DESC, "Watchdog counter" )
	field( VAL,  "0" )
	field( EGU,  "counts" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV")
}


# SIOC:SYS0:ML01:AO481
# This is the correct frequency counter frequency
# used to guard against accidental incorrect entries.
record( ao, "OSC:LT10:20:FS_OSC_TGT_FREQ" )
{
	field( DESC, "Osc. Target Freq" )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "Hz" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}


# SIOC:SYS0:ML01:AO482
# The time (in nanoseconds) for the laser pulse. Setting this
# will change phase shifts (and if enabled, triggers) to produce a laser
# output pulse at this time as measured on the frequency counter
record( ao, "OSC:LT10:20:FS_TGT_TIME" )
{
	field( DESC, "Target Time (Phase Offset)" )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "ns" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Dial Coordinates support for FS_TGT_TIME
# Consists of two PVs, FS_TGT_TIME_DIAL and FS_TGT_TIME_OFFSET
# DIAL + OFFSET = FS_TGT_TIME
# FWDPROP calc record monitors FS_TGT_TIME and OFFSET and recalculates DIAL
# REVPROP calc record montiors DIAL and recalculates FS_TGT_TIME
record( ao, "OSC:LT10:20:FS_TGT_TIME_DIAL" )
{
    field( DESC, "Target Time (Dial Coord)" )
    field( PREC, "6" )
    field( EGU,  "ns" )
    field( PINI, "YES" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ao, "OSC:LT10:20:FS_TGT_TIME_OFFSET" )
{
    field( DESC, "Target Time Dial Offset" )
    field( VAL,  "0" )
    field( PREC, "6" )
    field( EGU,  "ns" )
    field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( calcout, "OSC:LT10:20:FS_TGT_TIME_FWDPROP" )
{
    field( DESC, "Target Time FWD Propagation" )
    field( INPA, "OSC:LT10:20:FS_TGT_TIME CP MS" )
    field( INPB, "OSC:LT10:20:FS_TGT_TIME_OFFSET CP MS" )
    field( CALC, "A-B" )
    field( OUT,  "OSC:LT10:20:FS_TGT_TIME_DIAL PP MS" )
    field( OOPT, "On Change" )
    field( EGU,  "ns" )
    field( PREC, "6" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( calcout, "OSC:LT10:20:FS_TGT_TIME_REVPROP" )
{
    field( DESC, "Target Time REV Propagation" )
    field( INPA, "OSC:LT10:20:FS_TGT_TIME_DIAL CP MS" )
    field( INPB, "OSC:LT10:20:FS_TGT_TIME_OFFSET NPP MS" )
    field( CALC, "A+B" )
    field( OUT,  "OSC:LT10:20:FS_TGT_TIME PP MS" )
    field( OOPT, "On Change" )
    field( EGU,  "ns" )
    field( PREC, "6" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# SIOC:SYS0:ML01:AO483
# Use for calibration.  This should NOT be on a top level panel.
# Toggle to 1 to run a calibration cycle
# Set back to zero automatically when done
record( bo, "OSC:LT10:20:FS_START_CALIB" )
{
	field( DESC, "Start Calib." )
	field( VAL,  "0" )
	field( ZNAM, "Ready" )
	field( ONAM, "Calibrating" )
	field( ZSV,  "NO_ALARM" )
	field( OSV,  "MINOR" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC OSV ZSV COSV")
}


# SIOC:SYS0:ML01:AO484
# Enable time control
# When this is 0, the high level app does not attempt to control the laser time and it can be operated manually (interaction with calibration and bucket jump detection has not been checked).
record( bo, "OSC:LT10:20:FS_ENABLE_TIME_CTRL" )
{
	field( DESC, "Enable time control" )
	field( VAL,  "0" )
	field( ZNAM, "Disabled" )
	field( ONAM, "Enabled" )
	field( ZSV,  "MINOR" )
	field( OSV,  "NO_ALARM" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC OSV ZSV COSV")
}


# SIOC:SYS0:ML01:AO485
# Set to 1 to indicate when the software is busy - not fully
# implemented yet
record( bo, "OSC:LT10:20:FS_CTRL_BUSY" )
{
	field( DESC, "FS Control Busy" )
	field( VAL,  "0" )
	field( ZNAM, "Idle" )
	field( ONAM, "Busy" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC OSV ZSV COSV")
}

# Time Interval Counter measurement error range
# Monitor for bucket jumps
record( ao, "OSC:LT10:20:FS_TIC_ERROR" )
{
	field( DESC, "TIC Meas. Range." )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "ticks" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# SIOC:SYS0:ML01:AO486
# Timing error
# Difference between measured laser time (on interval counter) and desired time.
# Indicates any errors on the timing control.
# Note that the time interval counter only has ~10ps resolution
# so this is used to detect large jumps.
# The actual laser stability is
# much better than 1ps, but can't be measured this way
record( ao, "OSC:LT10:20:FS_TIMING_ERROR" )
{
	field( DESC, "Timing Error" )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "ns" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}


# SIOC:SYS0:ML01:AO487
# Laser OK
# signal levels are OK for the loop to operate
record( bo, "OSC:LT10:20:FS_LASER_OK" )
{
	field( DESC, "Laser signal level OK" )
	field( VAL,  "0" )
	field( ZNAM, "Low" )
	field( ONAM, "OK" )
	field( ZSV,  "MINOR" )
	field( OSV,  "NO_ALARM" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC OSV ZSV COSV")
}

# SIOC:SYS0:ML01:AO487.DESC
# string PV to indicate the latest error
# Note: Could change to a waveform of characters for longer strings
record( stringout, "OSC:LT10:20:FS_STATUS" )
{
	field( DESC, "FS Control Status" )
	field( VAL,  "" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC")
}


# SIOC:SYS0:ML01:AO488
# set to 1 (toggle) to enable automatic bucket correction.
record( bo, "OSC:LT10:20:FS_ENABLE_BUCKET_FIX" )
{
	field( DESC, "Auto bucket corr." )
	field( VAL,  "0" )
	field( ZNAM, "Disabled" )
	field( ONAM, "Enabled" )
	field( ZSV,  "MINOR" )
	field( OSV,  "NO_ALARM" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC OSV ZSV COSV")
}


# SIOC:SYS0:ML01:AO489
# trigger delay
# (not on top panel)..
# Internal program information on timing delays
record( ao, "OSC:LT10:20:FS_TRIGGER_DELAY" )
{
	field( DESC, "Trigger Delay" )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "ns" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}


# SIOC:SYS0:ML01:AO490
# timing offset
# (not on top panel)
# Internal program information on timing delays
record( ao, "OSC:LT10:20:FS_TIMING_OFFSET" )
{
	field( DESC, "Timing Offset" )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "ns" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}


# SIOC:SYS0:ML01:AO491
# Enable trigger control
# If enabled the software will
# move the trigger as well as the phase control to allow long timing moves
record( bo, "OSC:LT10:20:FS_ENABLE_TRIGGER" )
{
	field( DESC, "Trigger Ctrl Enabled" )
	field( VAL,  "0" )
	field( ZNAM, "Disabled" )
	field( ONAM, "Enabled" )
	field( ZSV,  "MINOR" )
	field( OSV,  "NO_ALARM" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC OSV ZSV COSV")
}


# SIOC:SYS0:ML01:AO492
# Buckets error
# In the event of a timing jump this indicates
# how many buckets of 3808MHz (8 X 476) have been jumped
record( longout, "OSC:LT10:20:FS_BUCKET_ERROR" )
{
	field( DESC, "Buckets of 3808MHz Error" )
	field( VAL,  "0" )
	field( EGU,  "buckets" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV")
}


# SIOC:SYS0:ML01:AO493
# Error from integer buckets
# If near zero, < 50ps, this indicates that the timing problem
# is a bucket jump.
# If larger, this indicates some other type of failure that
# cannot be corrected with bucket changes.
record( ao, "OSC:LT10:20:FS_UNFIXED_ERROR" )
{
	field( DESC, "Err from integer buckets" )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "ps" )
	field( HIGH, "50" )
	field( HIHI, "200" )
	field( HSV,  "MINOR" )
	field( HHSV, "MAJOR" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

#SIOC:SYS0:ML01:AO494
# Bucket corrects since reset
record( longout, "OSC:LT10:20:FS_CORRECTION_CNT" )
{
	field( DESC, "Bucket corrects since reset" )
	field( VAL,  "0" )
	field( EGU,  "corrects" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV")
}

#SIOC:SYS0:ML01:AO495
# Phase Degrees S band control
record( ao, "OSC:LT10:20:PDES" )
{
	field( DESC, "Degrees S band control" )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "deg 2856 MHz" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

#SIOC:SYS0:ML01:AO496
# Phase Offset Control (degrees)
record( ao, "OSC:LT10:20:POC" )
{
	field( DESC, "Phase Offset Control (degrees)" )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "deg 2856 MHz" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

#SIOC:SYS0:ML01:AO497
# ns offset
record( ao, "OSC:LT10:20:FS_NS_OFFSET" )
{
	field( DESC, "Phase offset (ns)" )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "ns" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}


#SIOC:SYS0:ML01:AO499
# last calibration error ns
record( ao, "OSC:LT10:20:FS_CALIB_ERROR" )
{
	field( DESC, "last calibration error ns" )
	field( VAL,  "0.0" )
	field( PREC, "6" )
	field( EGU,  "ns" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( waveform, "OSC:LT10:20:FS_CALIB_DATA" )
{
	field( DESC, "last calibration error ns" )
	field( PREC, "6" )
	field( NELM, "10000" )
	field( FTVL, "DOUBLE" )
	field( PINI, "YES" )
	info( autosaveFields, "VAL DESC EGU PREC" )
}

# BANNER_COLOR
# Integer that is evaluated in EDM to color code the screens for a given
# facility. In PCDS, this means (color names by Sherwin-Williams):
# 0 = N/A (Lazy Gray) 
# 1 = AMO (Blueblood)
# 2 = SXR (Dorian Gray)
# 3 = XPP (Straightforward Green)
# 4 = XCS (Gutsy Grape)
# 5 = CXI (Lusty Red)
# 6 = MEC (Social Butterfly)
# 7+ = Alarm (Flashing Red)
record( longout, "OSC:LT10:20:BANNER_COLOR" )
{
    field( DESC, "EDM banner color" )
    field( EGU,  "Units of color" )
    field( VAL,  "1" )
}

# EVR_TRIG_RATE
# Calculates the effective trigger rate coming from one or two EVR triggers
# used to fire the laser. The trigger rate PVs are passed in via vitara
# configuration substitution.
record( calc, "OSC:LT10:20:EVR_TRIG_RATE" )
{
    field( DESC, "EVR trigger rate" )
    field( EGU,  "Hz" )
    field( INPA, "EVR:LR10:LS01:EVENT2RATE CP NMS" )
    field( INPB, "TRIG:LT10:LS01:TCTL CP NMS")
    field( INPC, "0" )
    field( INPD, "0")
    field( CALC, "A*B+C*D" )
    field( PREC, "1" )
    field( HIHI, "120.1" )
    field( HHSV, "MAJOR" )
    field( HIGH, "120.1" )
    field( HSV,  "MINOR" )
    field( LOW,  "119.9" )
    field( LSV,  "MINOR" )
    field( LOLO, "119.9" )
    field (LLSV, "MAJOR" )
}

# The time in nanoseconds read by the SR620 frequency counter.
# The raw value is subtracted from a 40,000 ns reference interval
# so it can provides a comparable measurement to FS_TGT_TIME
# Resolution is 50ps for the raw counter
# 2014-02-19 klg: offset removed in favor of using offset record from SR620
record( calc, "OSC:LT10:20:FS_CTR_TIME" )
{
	field( DESC, "Counter Time" )
	field( INPA, "OSC:LT10:20:GetOffsetInvMeasMean CPP MS" )
    field( CALC, "A*1e9")
	field( PREC, "1" )
	field( EGU,  "ns" )
	info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}
#! Generated by VisualDCT v2.6
#! DBDSTART
#! DBDEND


#
# Vitara Automatic Operation
#
# Required macros:
#DEVDevice prefix for each new PV in this file
#CHDevice prefix including channel
#FREQ_MOTORPV name of Vitara freq motor
record(bo, "OSC:LT10:20:AUTO_MODE_ENABLE") {
  field(DESC, "Automatic mode enable/disable")
  field(ZNAM, "Manual")
  field(ONAM, "Automatic")
  field(ZSV, "MINOR")
  field(OSV, "NO_ALARM")
#  info(intentionally omitted)
}

record(ao, "OSC:LT10:20:PID_COARSE_AUTO_ON_LIMIT") {
  field(DESC, "PID AutoOn Threshhold")
  field(EGU, "V")
  field(PREC, "4")
  field(PINI, "YES")
  field(VAL, ".25")
  info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ao, "OSC:LT10:20:PID_COARSE_AUTO_OFF_LIMIT") {
  field(DESC, "PID AutoOff Threshhold")
  field(EGU, "V")
  field(PREC, "4")
  field(PINI, "YES")
  field(VAL, ".05")
  info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ao, "OSC:LT10:20:AUTO_SEARCH_TOL") {
  field(DESC, "Freq Err tolerance")
  field(EGU, "Hz")
  field(PREC, "0")
  field(PINI, "YES")
  field(VAL, "3")
  info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record( calcout, "OSC:LT10:20:PID_COARSE_FILT_ERR" ) {
	field( DESC, "Filtered PID error" )
	field( INPA, "OSC:LT10:20:PID_COARSE.ERR CP MS" )
	field( INPB, "0.8" )
	field( CALC, "A*(1-B)+VAL*B" )
  info(autosaveFields, "HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

# Enable coarse PID when the piezo element is too far from it's center
# ABS(piezo - center) > AUTO_ON_LIMIT
# and the chamber freq motor is not moving
# but only if we're still locked to protect against runaway conditions
record(calcout, "OSC:LT10:20:PID_COARSE_AUTO_ON") {
  field(DESC, "Enable coarse PID when too far")
	field( INPA, "OSC:LT10:20:PID_COARSE_FILT_ERR CP MS" )
  field(INPB, "OSC:LT10:20:PID_COARSE_AUTO_ON_LIMIT CP MS")
  field(INPC, "OSC:LT10:20:M1_MOTR_C.DMOV")
  field(INPD, "OSC:LT10:20:PHASE_LOCKED CP MS")
  field(CALC, "(ABS(A)>B) && C=1 && D=1")
  field(OUT, "OSC:LT10:20:PID_COARSE.FBON")
  field(OOPT, "Transition To Non-zero")
  field(OCAL, "1")
  field(DISV, "0")
  field(SDIS, "OSC:LT10:20:AUTO_MODE_ENABLE")
  info(autosaveFields, "INPC")
}

# Disable PID when the piezo element is near it's center
# ABS(piezo - center) < AUTO_OFF_LIMIT
# or if we lose lock, so the motor doesn't walk off
# or if the RF lock is disabled
record(calcout, "OSC:LT10:20:PID_COARSE_AUTO_OFF") {
  field(DESC, "Disable coarse PID when at mean")
  field( INPA, "OSC:LT10:20:PID_COARSE_FILT_ERR CP MS" )
  field(INPB, "OSC:LT10:20:PID_COARSE_AUTO_OFF_LIMIT CP MS")
#  field(INPC, "OSC:LT10:20:M1_MOTR_C.DMOV")
  field(INPD, "OSC:LT10:20:PHASE_LOCKED CP MS")
  field(CALC, "((ABS(A)<B) )||D=0")
  field(OUT, "OSC:LT10:20:PID_COARSE.FBON")
  field(OOPT, "Transition To Non-zero")
  field(DOPT, "Use OCAL")
  field(DISV, "0")
  field(SDIS, "OSC:LT10:20:AUTO_MODE_ENABLE")
}

record(ao, "OSC:LT10:20:FREQ_SEARCH_VEL") {
  field(DESC, "Motor spd during Freq Srch")
  field(EGU, "mm/sec")
  field(PREC, "4")
  field(VAL, "0.01")
  field(PINI, "YES")
  field(FLNK, "OSC:LT10:20:FREQ_MOTOR_VEL_CALC PP NMS")
  info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(ao, "OSC:LT10:20:PID_COARSE_VEL") {
  field(DESC, "Motor spd during PID op")
  field(EGU, "mm/sec")
  field(PREC, "4")
  field(VAL, "0.0001")
  field(PINI, "YES")
  field(FLNK, "OSC:LT10:20:FREQ_MOTOR_VEL_CALC PP NMS")
  info(autosaveFields, "VAL HHSV HSV LSV LLSV HIHI HIGH LOW LOLO")
}

record(calcout, "OSC:LT10:20:FREQ_MOTOR_VEL_CALC") {
  field(DESC, "Freq motor velocity calc")
  field(INPA, "OSC:LT10:20:PID_COARSE.FBON CP")
  field(INPB, "OSC:LT10:20:FREQ_SEARCH_VEL NPP NMS")
  field(INPC, "OSC:LT10:20:PID_COARSE_VEL NPP NMS")
  field(CALC, "A=0?B:C")
  field(OUT, "OSC:LT10:20:M1_MOTR_C.VELO CA NMS")
#  field(DISV, "0")
#  field(SDIS, "OSC:LT10:20:AUTO_MODE_ENABLE")
}

record(calcout, "OSC:LT10:20:AUTO_SEARCH_CALC") {
  field(DESC, "Auto Search watcher")
  field(SCAN, "2 second")
  field(INPA, "OSC:LT10:20:FREQ_ERR_LAST_N_RMS NPP MS")
  field(INPB, "OSC:LT10:20:AUTO_SEARCH_TOL     NPP NMS")
  field(INPD, "OSC:LT10:20:PHASE_LOCKED NPP NMS")
  field(INPE, "OSC:LT10:20:FREQ_SEARCH_ACTIVE  NPP MS")
  field(CALC, "A>B&&!D&&!E")
  field(OUT, "OSC:LT10:20:FREQ_SEARCH_START    PP NMS")
  field(OOPT, "When Non-zero")
  field(DISV, "0")
  field(SDIS, "OSC:LT10:20:AUTO_MODE_ENABLE")
}

record(calcout, "OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC") {
  field(DESC, "Auto RF Lock watcher")
  field(SCAN, "2 second")
  field(INPA, "OSC:LT10:20:CH1_DIODE_PWR_RMS  NPP MS")
  field(INPB, "OSC:LT10:20:CH1_DIODE_PWR.LOLO NPP MS")
  field(INPC, "OSC:LT10:20:CH1_DIODE_PWR.HIHI NPP MS")
  field(INPD, "OSC:LT10:20:CH1_RF_PWR_RMS     NPP MS")
  field(INPE, "OSC:LT10:20:CH1_RF_PWR.LOLO    NPP MS")
  field(INPF, "OSC:LT10:20:CH1_RF_PWR.HIHI    NPP MS")
  field(INPG, "OSC:LT10:20:FREQ_SEARCH_ACTIVE CP MS")
  field(CALC, "(A>B)&&(A<C)&&(D>E)&&(D<F)&&!G")
  field(OUT, "OSC:LT10:20:RF_LOCK_ENABLE PP NMS")
#field( OOPT, "On Change" )
  field(DISV, "0")
  field(SDIS, "OSC:LT10:20:AUTO_MODE_ENABLE")
}

#! Further lines contain data used by VisualDCT
#! View(0,0,1.0)
#! Record("OSC:LT10:20:AUTO_MODE_ENABLE",724,414,0,0,"OSC:LT10:20:AUTO_MODE_ENABLE")
#! Field("OSC:LT10:20:AUTO_MODE_ENABLE.VAL",16777215,1,"OSC:LT10:20:AUTO_MODE_ENABLE.VAL")
#! Record("OSC:LT10:20:PID_COARSE_AUTO_ON_LIMIT",252,14,0,0,"OSC:LT10:20:PID_COARSE_AUTO_ON_LIMIT")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_ON_LIMIT.VAL",16777215,0,"OSC:LT10:20:PID_COARSE_AUTO_ON_LIMIT.VAL")
#! Record("OSC:LT10:20:PID_COARSE_AUTO_OFF_LIMIT",1180,14,0,0,"OSC:LT10:20:PID_COARSE_AUTO_OFF_LIMIT")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_OFF_LIMIT.VAL",16777215,1,"OSC:LT10:20:PID_COARSE_AUTO_OFF_LIMIT.VAL")
#! Record("OSC:LT10:20:AUTO_SEARCH_TOL",1188,474,0,0,"OSC:LT10:20:AUTO_SEARCH_TOL")
#! Field("OSC:LT10:20:AUTO_SEARCH_TOL.VAL",16777215,1,"OSC:LT10:20:AUTO_SEARCH_TOL.VAL")
#! Record("OSC:LT10:20:PID_COARSE_AUTO_ON",496,51,0,0,"OSC:LT10:20:PID_COARSE_AUTO_ON")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_ON.INPA",16777215,1,"OSC:LT10:20:PID_COARSE_AUTO_ON.INPA")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_ON.INPB",16777215,0,"OSC:LT10:20:PID_COARSE_AUTO_ON.INPB")
#! Link("OSC:LT10:20:PID_COARSE_AUTO_ON.INPB","OSC:LT10:20:PID_COARSE_AUTO_ON_LIMIT.VAL")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_ON.INPC",16777215,1,"OSC:LT10:20:PID_COARSE_AUTO_ON.INPC")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_ON.INPD",16777215,1,"OSC:LT10:20:PID_COARSE_AUTO_ON.INPD")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_ON.OUT",16777215,1,"OSC:LT10:20:PID_COARSE_AUTO_ON.OUT")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_ON.SDIS",16777215,1,"OSC:LT10:20:PID_COARSE_AUTO_ON.SDIS")
#! Link("OSC:LT10:20:PID_COARSE_AUTO_ON.SDIS","OSC:LT10:20:AUTO_MODE_ENABLE.VAL")
#! Record("OSC:LT10:20:PID_COARSE_AUTO_OFF",924,65,0,0,"OSC:LT10:20:PID_COARSE_AUTO_OFF")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_OFF.INPA",16777215,1,"OSC:LT10:20:PID_COARSE_AUTO_OFF.INPA")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_OFF.INPB",16777215,1,"OSC:LT10:20:PID_COARSE_AUTO_OFF.INPB")
#! Link("OSC:LT10:20:PID_COARSE_AUTO_OFF.INPB","OSC:LT10:20:PID_COARSE_AUTO_OFF_LIMIT.VAL")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_OFF.INPD",16777215,1,"OSC:LT10:20:PID_COARSE_AUTO_OFF.INPD")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_OFF.OUT",16777215,1,"OSC:LT10:20:PID_COARSE_AUTO_OFF.OUT")
#! Field("OSC:LT10:20:PID_COARSE_AUTO_OFF.SDIS",16777215,0,"OSC:LT10:20:PID_COARSE_AUTO_OFF.SDIS")
#! Link("OSC:LT10:20:PID_COARSE_AUTO_OFF.SDIS","OSC:LT10:20:AUTO_MODE_ENABLE.VAL")
#! Record("OSC:LT10:20:FREQ_SEARCH_VEL",152,460,0,0,"OSC:LT10:20:FREQ_SEARCH_VEL")
#! Field("OSC:LT10:20:FREQ_SEARCH_VEL.FLNK",16777215,1,"OSC:LT10:20:FREQ_SEARCH_VEL.FLNK")
#! Link("OSC:LT10:20:FREQ_SEARCH_VEL.FLNK","OSC:LT10:20:FREQ_MOTOR_VEL_CALC")
#! Field("OSC:LT10:20:FREQ_SEARCH_VEL.VAL",16777215,1,"OSC:LT10:20:FREQ_SEARCH_VEL.VAL")
#! Record("OSC:LT10:20:PID_COARSE_VEL",160,620,0,0,"OSC:LT10:20:PID_COARSE_VEL")
#! Field("OSC:LT10:20:PID_COARSE_VEL.FLNK",16777215,1,"OSC:LT10:20:PID_COARSE_VEL.FLNK")
#! Link("OSC:LT10:20:PID_COARSE_VEL.FLNK","OSC:LT10:20:FREQ_MOTOR_VEL_CALC")
#! Field("OSC:LT10:20:PID_COARSE_VEL.VAL",16777215,1,"OSC:LT10:20:PID_COARSE_VEL.VAL")
#! Record("OSC:LT10:20:FREQ_MOTOR_VEL_CALC",448,552,0,0,"OSC:LT10:20:FREQ_MOTOR_VEL_CALC")
#! Field("OSC:LT10:20:FREQ_MOTOR_VEL_CALC.INPA",16777215,1,"OSC:LT10:20:FREQ_MOTOR_VEL_CALC.INPA")
#! Field("OSC:LT10:20:FREQ_MOTOR_VEL_CALC.INPB",16777215,0,"OSC:LT10:20:FREQ_MOTOR_VEL_CALC.INPB")
#! Link("OSC:LT10:20:FREQ_MOTOR_VEL_CALC.INPB","OSC:LT10:20:FREQ_SEARCH_VEL.VAL")
#! Field("OSC:LT10:20:FREQ_MOTOR_VEL_CALC.INPC",16777215,0,"OSC:LT10:20:FREQ_MOTOR_VEL_CALC.INPC")
#! Link("OSC:LT10:20:FREQ_MOTOR_VEL_CALC.INPC","OSC:LT10:20:PID_COARSE_VEL.VAL")
#! Field("OSC:LT10:20:FREQ_MOTOR_VEL_CALC.OUT",16777215,1,"OSC:LT10:20:FREQ_MOTOR_VEL_CALC.OUT")
#! Field("OSC:LT10:20:FREQ_MOTOR_VEL_CALC.SDIS",16777215,1,"OSC:LT10:20:FREQ_MOTOR_VEL_CALC.SDIS")
#! Link("OSC:LT10:20:FREQ_MOTOR_VEL_CALC.SDIS","OSC:LT10:20:AUTO_MODE_ENABLE.VAL")
#! Record("OSC:LT10:20:AUTO_SEARCH_CALC",976,491,0,0,"OSC:LT10:20:AUTO_SEARCH_CALC")
#! Field("OSC:LT10:20:AUTO_SEARCH_CALC.INPA",16777215,1,"OSC:LT10:20:AUTO_SEARCH_CALC.INPA")
#! Field("OSC:LT10:20:AUTO_SEARCH_CALC.INPB",16777215,1,"OSC:LT10:20:AUTO_SEARCH_CALC.INPB")
#! Link("OSC:LT10:20:AUTO_SEARCH_CALC.INPB","OSC:LT10:20:AUTO_SEARCH_TOL.VAL")
#! Field("OSC:LT10:20:AUTO_SEARCH_CALC.INPD",16777215,1,"OSC:LT10:20:AUTO_SEARCH_CALC.INPD")
#! Field("OSC:LT10:20:AUTO_SEARCH_CALC.INPE",16777215,1,"OSC:LT10:20:AUTO_SEARCH_CALC.INPE")
#! Field("OSC:LT10:20:AUTO_SEARCH_CALC.OUT",16777215,1,"OSC:LT10:20:AUTO_SEARCH_CALC.OUT")
#! Field("OSC:LT10:20:AUTO_SEARCH_CALC.SDIS",16777215,0,"OSC:LT10:20:AUTO_SEARCH_CALC.SDIS")
#! Link("OSC:LT10:20:AUTO_SEARCH_CALC.SDIS","OSC:LT10:20:AUTO_MODE_ENABLE.VAL")
#! Record("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC",24,23,0,0,"OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC")
#! Field("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPA",16777215,1,"OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPA")
#! Field("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPB",16777215,1,"OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPB")
#! Field("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPC",16777215,1,"OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPC")
#! Field("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPD",16777215,1,"OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPD")
#! Field("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPE",16777215,1,"OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPE")
#! Field("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPF",16777215,1,"OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPF")
#! Field("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPG",16777215,1,"OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.INPG")
#! Field("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.OUT",16777215,1,"OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.OUT")
#! Field("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.SDIS",16777215,1,"OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.SDIS")
#! Link("OSC:LT10:20:AUTO_RF_LOCK_ENABLE_CALC.SDIS","OSC:LT10:20:AUTO_MODE_ENABLE.VAL")
#! Generated by VisualDCT v2.6
#! DBDSTART
#! DBDEND


#
# vitaraFreqSearch.template
#
# Required macros:
#DEV  	- PV prefix for all vitara PV's
#FREQ_MOTOR- Motor PV name
#FREQ- Freq counter PV name
# These first records provide a local PV with a common
# prefix to make it easier to share screens and db templates
record(ao, "OSC:LT10:20:FREQ_CUR") {
  field(DESC, "Current Vitara Freq")
  field(DOL, "OSC:LT10:20:FREQ_RBCK CP MS")
  field(OMSL, "closed_loop")
  field(EGU, "Hz")
  field(PREC, "0")
  field(FLNK, "OSC:LT10:20:FREQ_ERR")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ai, "OSC:LT10:20:FREQ_MOTOR_POS") {
  field(DESC, "Cur Freq motor pos")
  field(INP, "OSC:LT10:20:M1_MOTR_C.RBV CP MS")
  field(EGU, "mm")
  field(PREC, "6")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC INP")
}

# Frequence target set point
record(ao, "OSC:LT10:20:FREQ_SP") {
  field(DESC, "Freq target set point")
  field(VAL, "67999964")
  field(EGU, "Hz")
  field(PREC, "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calc, "OSC:LT10:20:FREQ_ERR") {
  field(DESC, "Freq Err in Hz")
  field(CALC, "A-B")
  field(INPA, "OSC:LT10:20:FREQ_CUR NPP NMS")
  field(INPB, "OSC:LT10:20:FREQ_SP CP")
  field(EGU, "Hz")
  field(PREC, "3")
  field(FLNK, "OSC:LT10:20:FREQ_ERR_SMOOTHED PP MS")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

#
# Keep FREQ_ERR Limits consistent w/ search and lock criteria
#

# Propagate FREQ_ERR.HIHI
# to FREQ_ERR_RMS.HIHI, FREQ_ERR.LOLO, and FREQ_ERR_RMS.LOLO
record( dfanout, "OSC:LT10:20:FREQ_ERR_UPDATE_HIHI" )
{
	field( OMSL, "closed_loop" )
	field( DOL,  "OSC:LT10:20:FREQ_ERR.HIHI  CPP NMS" )
	field( OUTA, "OSC:LT10:20:FREQ_ERR_RMS.HIHI NPP NMS" )
	field( FLNK, "OSC:LT10:20:FREQ_ERR_CALC_LOLO" )
}
record( calc, "OSC:LT10:20:FREQ_ERR_CALC_LOLO" )
{
	field( INPA, "OSC:LT10:20:FREQ_ERR.HIHI NPP NMS" )
	field( CALC, "-A" )
	field( FLNK, "OSC:LT10:20:FREQ_ERR_UPDATE_LOLO" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}
record( dfanout, "OSC:LT10:20:FREQ_ERR_UPDATE_LOLO" )
{
	field( OMSL, "closed_loop" )
	field( DOL,  "OSC:LT10:20:FREQ_ERR_CALC_LOLO" )
	field( OUTA, "OSC:LT10:20:FREQ_ERR.LOLO NPP NMS" )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_RMS.LOLO NPP NMS" )
}

# Propagate FREQ_TOLERANCE
# to FREQ_ERR.HIGH, FREQ_ERR_RMS.HIGH, FREQ_ERR.LOW, and FREQ_ERR_RMS.LOW
record( dfanout, "OSC:LT10:20:FREQ_ERR_UPDATE_HIGH" )
{
	field( OMSL, "closed_loop" )
	field( DOL,  "OSC:LT10:20:FREQ_TOLERANCE CPP NMS" )
	field( OUTA, "OSC:LT10:20:FREQ_ERR.HIGH NPP NMS" )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_RMS.HIGH NPP NMS" )
}
record( calc, "OSC:LT10:20:FREQ_ERR_CALC_LOW" )
{
	field( INPA, "OSC:LT10:20:FREQ_TOLERANCE CPP NMS" )
	field( CALC, "-A" )
	field( FLNK, "OSC:LT10:20:FREQ_ERR_UPDATE_LOW" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}
record( dfanout, "OSC:LT10:20:FREQ_ERR_UPDATE_LOW" )
{
	field( OMSL, "closed_loop" )
	field( DOL,  "OSC:LT10:20:FREQ_ERR_CALC_LOW" )
	field( OUTA, "OSC:LT10:20:FREQ_ERR.LOW NPP NMS" )
	field( OUTB, "OSC:LT10:20:FREQ_ERR_RMS.LOW NPP NMS" )
	field( FLNK, "OSC:LT10:20:FREQ_ERR_UPDATE_HIGH" )
}


# SMOO field updated by OSC:LT10:20:FREQ_ERR_SMOOTH
record(ai, "OSC:LT10:20:FREQ_ERR_SMOOTHED") {
  field(DESC, "Freq Err in Hz")
  field(SMOO, "0.5")
  field(INP, "OSC:LT10:20:FREQ_ERR")
  field(EGU, "Hz")
  field(PREC, "3")
  field(FLNK, "OSC:LT10:20:FREQ_MOTOR_TGT PP NMS")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:FREQ_ERR_SMOOTH") {
  field(DESC, "IIR filter smooth factor")
  field(VAL, "0.5")
  field(OUT, "OSC:LT10:20:FREQ_ERR_SMOOTHED.SMOO")
  field(PINI, "YES")
  field(PREC, "4")
  info(autosaveFields, "VAL HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Calibrate for each system,do not merge or copy VAL.
record(ao, "OSC:LT10:20:FREQ_ERR_CORRECTION") {
  field(DESC, "Freq err corr factor")
  field(VAL, "149800")
  field(EGU, "Hz/mm")
  field(PINI, "YES")
  field(PREC, "0")
  info(autosaveFields, "VAL HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(calcout, "OSC:LT10:20:FREQ_MOTOR_TGT") {
  field(DESC, "Calc chamber motor target")
  field(CALC, "C - A/B")
  field(INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED NPP NMS")
  field(INPB, "OSC:LT10:20:FREQ_ERR_CORRECTION NPP NMS")
  field(INPC, "OSC:LT10:20:FREQ_MOTOR_POS CA MS")
  field(EGU, "mm")
  field(PREC, "5")
  info(autosaveFields, "HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Only process this PV when you want to move the motor
# to OSC:LT10:20:FREQ_MOTOR_TGT
record(ao, "OSC:LT10:20:FREQ_MOTOR_POS_GOTO") {
  field(DESC, "Go to calc motor pos")
  field(OMSL, "closed_loop")
  field(DOL, "OSC:LT10:20:FREQ_MOTOR_TGT NPP MS")
  field(OUT, "OSC:LT10:20:M1_MOTR_C.VAL PP")
  field(EGU, "mm")
  field(FLNK, "OSC:LT10:20:FREQ_RETRY_COUNTER PP NMS")
  info(autosaveFields, "VAL HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(bo, "OSC:LT10:20:FREQ_SEARCH_IN_TOL") {
  field(DESC, "Freq search in tol")
  field(ZNAM, "Not OK")
  field(ZSV, "MINOR")
  field(ONAM, "OK")
  field(OSV, "NO_ALARM")
#  info(autosaveFields, "intentionally blank")
}

record( mbbo, "OSC:LT10:20:FREQ_SEARCH_STATE" )
{
	field( DESC, "Freq search state" )
	field( VAL,  "1" )
	field( ZRVL, "0" )	field( ZRST, "Searching" )
	field( ZRSV, "MINOR")
	field( ONVL, "1" )	field( ONST, "Idle" )
	field( TWVL, "2" )	field( TWST, "Found" )
	field( THVL, "3" )	field( THST, "Failed" )
	field( THSV, "MAJOR" )
	field( PINI, "YES" )
	field( FLNK, "OSC:LT10:20:FREQ_SEARCH_ACTIVE" )
#  info(autosaveFields, "intentionally blank")
}

record( calc, "OSC:LT10:20:FREQ_SEARCH_ACTIVE" )
{
  field(DESC, "Freq search in progress")
	field( INPA, "OSC:LT10:20:FREQ_SEARCH_STATE NPP MS" )
	field( CALC, "0=A" )
#  info(autosaveFields, "intentionally blank")
}

record( seq, "OSC:LT10:20:FREQ_SEARCH_START" )
{
  field(DESC, "Start frequency search")
  field(DOL1, "0")
  field(LNK1, "OSC:LT10:20:FREQ_RETRY_COUNTER PP")
  field(DLY2, "0.5")
	field( DOL2, "0" )
	field( LNK2, "OSC:LT10:20:FREQ_SEARCH_STATE PP" )
#	field( DOL2, "1" )
#	field( LNK2, "OSC:LT10:20:FREQ_SEARCH_ACTIVE PP" )
}

record( seq, "OSC:LT10:20:FREQ_SEARCH_STOP" )
{
	field( DESC, "Stop frequency search" )
	field( DOL1, "1" )
	field( LNK1, "OSC:LT10:20:FREQ_SEARCH_STATE PP" )
	field( DOL2, "0" )
	field( LNK2, "OSC:LT10:20:FREQ_RETRY_COUNTER PP" )
}

record( calcout, "OSC:LT10:20:FREQ_DO_RETRY" )
{
  field(DESC, "Retry if not at freq")
# If motor is done moving, initiate another retry
  field(INPA, "OSC:LT10:20:M1_MOTR_C.DMOV CA")
  field(CALC, "A==1")
	field( SCAN, "5 second" )

  field(OOPT, "When Non-zero")
  field(DOPT, "Use OCAL")
  field(OCAL, "1")
  field(ODLY, "2.5")
  field(OUT, "OSC:LT10:20:FREQ_MOTOR_POS_GOTO.PROC")

	# Disabled when FREQ_SEARCH_ACTIVE is 0
  field(DISV, "0")
  field(SDIS, "OSC:LT10:20:FREQ_SEARCH_ACTIVE")
#  info(autosaveFields, "intentionally blank")
}

# Is the frequency search within tolerance?
record(calcout, "OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC") {
  field(DESC, "Frequency tolerance calc")
  field(VAL, "0")
  field(INPA, "OSC:LT10:20:FREQ_ERR_SMOOTHED CP MS")
  field(INPB, "OSC:LT10:20:FREQ_TOLERANCE NPP")
  field(CALC, "abs(A) <= B")
  field(OUT, "OSC:LT10:20:FREQ_SEARCH_IN_TOL PP")
  field(FLNK, "OSC:LT10:20:FREQ_SEARCH_MONITOR PP NMS")
#  info(autosaveFields, "intentionally blank")
}

# Monitor the frequency search and shut it down when done
record(calcout, "OSC:LT10:20:FREQ_SEARCH_MONITOR") {
  field(DESC, "Monitor frequency search")
	field( INPA, "OSC:LT10:20:FREQ_SEARCH_IN_TOL       NPP NMS" )
	field( INPC, "OSC:LT10:20:M1_MOTR_C.DMOV              NPP NMS" )
	field( INPD, "OSC:LT10:20:FREQ_RETRY_COUNTER       NPP NMS" )
	field( INPE, "OSC:LT10:20:FREQ_RETRY_COUNTER.HIHI  NPP NMS" )
	field( INPF, "OSC:LT10:20:FREQ_ERR_LAST_N_STD      NPP NMS" )
	field( INPG, "OSC:LT10:20:FREQ_ERR_LAST_N_STD.HIHI NPP NMS" )
	field( INPH, "OSC:LT10:20:FREQ_MOTOR_TGT           NPP NMS" )
	field( INPI, "OSC:LT10:20:M1_MOTR_C.HLM               NPP NMS" )
	field( INPJ, "OSC:LT10:20:M1_MOTR_C.LLM               NPP NMS" )
	field( CALC, "(A && C) || ((D>=E)||(F>G)||(H>I)||(H<J))" )
	field( OCAL, "(A && C)?2:(((D>=E)||(F>G)||(H>I)||(H<J))?3:0)" )
	field( OUT,  "OSC:LT10:20:FREQ_SEARCH_STATE PP" )
  field(DOPT, "Use OCAL")
  field(OOPT, "When Non-zero")
	field( IVOA, "Set output to IVOV" )
	field( IVOV, "3" )
#  info(autosaveFields, "intentionally blank")
}

record(calc, "OSC:LT10:20:FREQ_RETRY_COUNTER") {
  field(DESC, "Number of coarse motor retries")
  field(INPA, "OSC:LT10:20:FREQ_RETRY_COUNTER NPP")
  field(CALC, "A+1")
	field( HIGH, "5" )
	field( HIHI, "10" )
	field( HSV,  "MINOR" )
	field( HHSV, "MAJOR" )
  field(PINI, "YES")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:FREQ_RETRY_MAX") {
  field(DESC, "Number retries")
	field( DOL,  "OSC:LT10:20:FREQ_RETRY_COUNTER.HIHI CP NMS" )
  field(PINI, "YES")
  info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record(ao, "OSC:LT10:20:FREQ_TOLERANCE") {
  field(DESC, "Freq Search Tolerance")
  field(VAL, "2")
  field(EGU, "Hz")
  field(PINI, "YES")
  info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# If normal OSC:LT10:20:FREQ_RBCK PV not available use this PV and change
# via caput to test frequency searches.
record(ao, "OSC:LT10:20:FREQ_TEST") {
  field(DESC, "Diag pv")
  field(VAL, "68000000")
  field(EGU, "Hz")
  field(PREC, "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(calcout, "OSC:LT10:20:FREQ_TEST_DECR") {
  field(INPA, "OSC:LT10:20:FREQ_TEST NPP NMS")
  field(CALC, "A - 1")
  field(OUT, "OSC:LT10:20:FREQ_TEST PP NMS")
}

record(calcout, "OSC:LT10:20:FREQ_TEST_INCR") {
  field(INPA, "OSC:LT10:20:FREQ_TEST NPP NMS")
  field(CALC, "A + 1")
  field(OUT, "OSC:LT10:20:FREQ_TEST PP NMS")
}

#! Further lines contain data used by VisualDCT
#! View(239,0,1.0)
#! Record("OSC:LT10:20:FREQ_CUR",220,560,0,0,"OSC:LT10:20:FREQ_CUR")
#! Field("OSC:LT10:20:FREQ_CUR.DOL",16777215,1,"OSC:LT10:20:FREQ_CUR.DOL")
#! Field("OSC:LT10:20:FREQ_CUR.FLNK",16777215,0,"OSC:LT10:20:FREQ_CUR.FLNK")
#! Link("OSC:LT10:20:FREQ_CUR.FLNK","OSC:LT10:20:FREQ_ERR")
#! Field("OSC:LT10:20:FREQ_CUR.VAL",16777215,0,"OSC:LT10:20:FREQ_CUR.VAL")
#! Record("OSC:LT10:20:FREQ_MOTOR_POS",840,268,0,0,"OSC:LT10:20:FREQ_MOTOR_POS")
#! Field("OSC:LT10:20:FREQ_MOTOR_POS.INP",16777215,1,"OSC:LT10:20:FREQ_MOTOR_POS.INP")
#! Field("OSC:LT10:20:FREQ_MOTOR_POS.VAL",16777215,0,"OSC:LT10:20:FREQ_MOTOR_POS.VAL")
#! Record("OSC:LT10:20:FREQ_SP",220,74,0,0,"OSC:LT10:20:FREQ_SP")
#! Field("OSC:LT10:20:FREQ_SP.VAL",16777215,0,"OSC:LT10:20:FREQ_SP.VAL")
#! Record("OSC:LT10:20:FREQ_ERR",240,286,0,0,"OSC:LT10:20:FREQ_ERR")
#! Field("OSC:LT10:20:FREQ_ERR.INPA",16777215,0,"OSC:LT10:20:FREQ_ERR.INPA")
#! Link("OSC:LT10:20:FREQ_ERR.INPA","OSC:LT10:20:FREQ_CUR.VAL")
#! Field("OSC:LT10:20:FREQ_ERR.INPB",16777215,0,"OSC:LT10:20:FREQ_ERR.INPB")
#! Link("OSC:LT10:20:FREQ_ERR.INPB","OSC:LT10:20:FREQ_SP.VAL")
#! Field("OSC:LT10:20:FREQ_ERR.FLNK",16777215,1,"OSC:LT10:20:FREQ_ERR.FLNK")
#! Link("OSC:LT10:20:FREQ_ERR.FLNK","OSC:LT10:20:FREQ_ERR_SMOOTHED")
#! Field("OSC:LT10:20:FREQ_ERR.VAL",16777215,1,"OSC:LT10:20:FREQ_ERR.VAL")
#! Record("OSC:LT10:20:FREQ_ERR_SMOOTHED",540,360,0,0,"OSC:LT10:20:FREQ_ERR_SMOOTHED")
#! Field("OSC:LT10:20:FREQ_ERR_SMOOTHED.INP",16777215,0,"OSC:LT10:20:FREQ_ERR_SMOOTHED.INP")
#! Link("OSC:LT10:20:FREQ_ERR_SMOOTHED.INP","OSC:LT10:20:FREQ_ERR.VAL")
#! Field("OSC:LT10:20:FREQ_ERR_SMOOTHED.FLNK",16777215,1,"OSC:LT10:20:FREQ_ERR_SMOOTHED.FLNK")
#! Link("OSC:LT10:20:FREQ_ERR_SMOOTHED.FLNK","OSC:LT10:20:FREQ_MOTOR_TGT")
#! Field("OSC:LT10:20:FREQ_ERR_SMOOTHED.SMOO",16777215,0,"OSC:LT10:20:FREQ_ERR_SMOOTHED.SMOO")
#! Field("OSC:LT10:20:FREQ_ERR_SMOOTHED.VAL",16777215,1,"OSC:LT10:20:FREQ_ERR_SMOOTHED.VAL")
#! Record("OSC:LT10:20:FREQ_ERR_SMOOTH",540,74,0,0,"OSC:LT10:20:FREQ_ERR_SMOOTH")
#! Field("OSC:LT10:20:FREQ_ERR_SMOOTH.OUT",16777215,0,"OSC:LT10:20:FREQ_ERR_SMOOTH.OUT")
#! Link("OSC:LT10:20:FREQ_ERR_SMOOTH.OUT","OSC:LT10:20:FREQ_ERR_SMOOTHED.SMOO")
#! Record("OSC:LT10:20:FREQ_ERR_CORRECTION",520,628,0,0,"OSC:LT10:20:FREQ_ERR_CORRECTION")
#! Field("OSC:LT10:20:FREQ_ERR_CORRECTION.VAL",16777215,1,"OSC:LT10:20:FREQ_ERR_CORRECTION.VAL")
#! Record("OSC:LT10:20:FREQ_MOTOR_TGT",860,446,0,0,"OSC:LT10:20:FREQ_MOTOR_TGT")
#! Field("OSC:LT10:20:FREQ_MOTOR_TGT.INPA",16777215,0,"OSC:LT10:20:FREQ_MOTOR_TGT.INPA")
#! Link("OSC:LT10:20:FREQ_MOTOR_TGT.INPA","OSC:LT10:20:FREQ_ERR_SMOOTHED.VAL")
#! Field("OSC:LT10:20:FREQ_MOTOR_TGT.INPB",16777215,0,"OSC:LT10:20:FREQ_MOTOR_TGT.INPB")
#! Link("OSC:LT10:20:FREQ_MOTOR_TGT.INPB","OSC:LT10:20:FREQ_ERR_CORRECTION.VAL")
#! Field("OSC:LT10:20:FREQ_MOTOR_TGT.INPC",16777215,0,"OSC:LT10:20:FREQ_MOTOR_TGT.INPC")
#! Link("OSC:LT10:20:FREQ_MOTOR_TGT.INPC","OSC:LT10:20:FREQ_MOTOR_POS.VAL")
#! Field("OSC:LT10:20:FREQ_MOTOR_TGT.VAL",16777215,1,"OSC:LT10:20:FREQ_MOTOR_TGT.VAL")
#! Record("OSC:LT10:20:FREQ_MOTOR_POS_GOTO",1140,460,0,0,"OSC:LT10:20:FREQ_MOTOR_POS_GOTO")
#! Field("OSC:LT10:20:FREQ_MOTOR_POS_GOTO.DOL",16777215,0,"OSC:LT10:20:FREQ_MOTOR_POS_GOTO.DOL")
#! Link("OSC:LT10:20:FREQ_MOTOR_POS_GOTO.DOL","OSC:LT10:20:FREQ_MOTOR_TGT.VAL")
#! Field("OSC:LT10:20:FREQ_MOTOR_POS_GOTO.OUT",16777215,1,"OSC:LT10:20:FREQ_MOTOR_POS_GOTO.OUT")
#! Field("OSC:LT10:20:FREQ_MOTOR_POS_GOTO.FLNK",16777215,1,"OSC:LT10:20:FREQ_MOTOR_POS_GOTO.FLNK")
#! Link("OSC:LT10:20:FREQ_MOTOR_POS_GOTO.FLNK","OSC:LT10:20:FREQ_RETRY_COUNTER")
#! Field("OSC:LT10:20:FREQ_MOTOR_POS_GOTO.PROC",16777215,1,"OSC:LT10:20:FREQ_MOTOR_POS_GOTO.PROC")
#! Record("OSC:LT10:20:FREQ_SEARCH_IN_TOL",1560,114,0,0,"OSC:LT10:20:FREQ_SEARCH_IN_TOL")
#! Field("OSC:LT10:20:FREQ_SEARCH_IN_TOL.VAL",16777215,1,"OSC:LT10:20:FREQ_SEARCH_IN_TOL.VAL")
#! Record("OSC:LT10:20:FREQ_SEARCH_ACTIVE",2120,434,0,0,"OSC:LT10:20:FREQ_SEARCH_ACTIVE")
#! Field("OSC:LT10:20:FREQ_SEARCH_ACTIVE.VAL",16777215,0,"OSC:LT10:20:FREQ_SEARCH_ACTIVE.VAL")
#! Record("OSC:LT10:20:FREQ_SEARCH_START",1500,372,0,0,"OSC:LT10:20:FREQ_SEARCH_START")
#! Field("OSC:LT10:20:FREQ_SEARCH_START.SDIS",16777215,1,"OSC:LT10:20:FREQ_SEARCH_START.SDIS")
#! Link("OSC:LT10:20:FREQ_SEARCH_START.SDIS","OSC:LT10:20:FREQ_SEARCH_ACTIVE.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_START.LNK1",16777215,1,"OSC:LT10:20:FREQ_SEARCH_START.LNK1")
#! Link("OSC:LT10:20:FREQ_SEARCH_START.LNK1","OSC:LT10:20:FREQ_RETRY_COUNTER.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_START.LNK2",16777215,1,"OSC:LT10:20:FREQ_SEARCH_START.LNK2")
#! Link("OSC:LT10:20:FREQ_SEARCH_START.LNK2","OSC:LT10:20:FREQ_SEARCH_ACTIVE.VAL")
#! Record("OSC:LT10:20:FREQ_DO_RETRY",1820,631,0,0,"OSC:LT10:20:FREQ_DO_RETRY")
#! Field("OSC:LT10:20:FREQ_DO_RETRY.INPA",16777215,1,"OSC:LT10:20:FREQ_DO_RETRY.INPA")
#! Field("OSC:LT10:20:FREQ_DO_RETRY.OUT",16777215,0,"OSC:LT10:20:FREQ_DO_RETRY.OUT")
#! Link("OSC:LT10:20:FREQ_DO_RETRY.OUT","OSC:LT10:20:FREQ_MOTOR_POS_GOTO.PROC")
#! Field("OSC:LT10:20:FREQ_DO_RETRY.SDIS",16777215,1,"OSC:LT10:20:FREQ_DO_RETRY.SDIS")
#! Link("OSC:LT10:20:FREQ_DO_RETRY.SDIS","OSC:LT10:20:FREQ_SEARCH_ACTIVE.VAL")
#! Record("OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC",1300,66,0,0,"OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC")
#! Field("OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.INPA",16777215,0,"OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.INPA")
#! Link("OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.INPA","OSC:LT10:20:FREQ_ERR_SMOOTHED.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.INPB",16777215,0,"OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.INPB")
#! Link("OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.INPB","OSC:LT10:20:FREQ_TOLERANCE.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.OUT",16777215,1,"OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.OUT")
#! Link("OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.OUT","OSC:LT10:20:FREQ_SEARCH_IN_TOL.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.FLNK",16777215,1,"OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.FLNK")
#! Link("OSC:LT10:20:FREQ_SEARCH_IN_TOL_CALC.FLNK","OSC:LT10:20:FREQ_SEARCH_MONITOR")
#! Record("OSC:LT10:20:FREQ_SEARCH_MONITOR",1840,55,0,0,"OSC:LT10:20:FREQ_SEARCH_MONITOR")
#! Field("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPA",16777215,0,"OSC:LT10:20:FREQ_SEARCH_MONITOR.INPA")
#! Link("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPA","OSC:LT10:20:FREQ_SEARCH_IN_TOL.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPC",16777215,1,"OSC:LT10:20:FREQ_SEARCH_MONITOR.INPC")
#! Field("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPD",16777215,0,"OSC:LT10:20:FREQ_SEARCH_MONITOR.INPD")
#! Link("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPD","OSC:LT10:20:FREQ_RETRY_COUNTER.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPE",16777215,1,"OSC:LT10:20:FREQ_SEARCH_MONITOR.INPE")
#! Link("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPE","OSC:LT10:20:FREQ_RETRY_MAX.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_MONITOR.OUT",16777215,1,"OSC:LT10:20:FREQ_SEARCH_MONITOR.OUT")
#! Link("OSC:LT10:20:FREQ_SEARCH_MONITOR.OUT","OSC:LT10:20:FREQ_SEARCH_ACTIVE.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPF",16777215,1,"OSC:LT10:20:FREQ_SEARCH_MONITOR.INPF")
#! Field("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPG",16777215,0,"OSC:LT10:20:FREQ_SEARCH_MONITOR.INPG")
#! Link("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPG","OSC:LT10:20:FREQ_TOLERANCE.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPH",16777215,0,"OSC:LT10:20:FREQ_SEARCH_MONITOR.INPH")
#! Link("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPH","OSC:LT10:20:FREQ_MOTOR_TGT.VAL")
#! Field("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPI",16777215,1,"OSC:LT10:20:FREQ_SEARCH_MONITOR.INPI")
#! Field("OSC:LT10:20:FREQ_SEARCH_MONITOR.INPJ",16777215,1,"OSC:LT10:20:FREQ_SEARCH_MONITOR.INPJ")
#! Record("OSC:LT10:20:FREQ_RETRY_COUNTER",1520,640,0,0,"OSC:LT10:20:FREQ_RETRY_COUNTER")
#! Field("OSC:LT10:20:FREQ_RETRY_COUNTER.VAL",16777215,1,"OSC:LT10:20:FREQ_RETRY_COUNTER.VAL")
#! Field("OSC:LT10:20:FREQ_RETRY_COUNTER.INPA",16777215,0,"OSC:LT10:20:FREQ_RETRY_COUNTER.INPA")
#! Link("OSC:LT10:20:FREQ_RETRY_COUNTER.INPA","OSC:LT10:20:FREQ_RETRY_COUNTER.VAL")
#! Field("OSC:LT10:20:FREQ_RETRY_COUNTER.SDIS",16777215,1,"OSC:LT10:20:FREQ_RETRY_COUNTER.SDIS")
#! Link("OSC:LT10:20:FREQ_RETRY_COUNTER.SDIS","OSC:LT10:20:FREQ_SEARCH_ACTIVE.VAL")
#! Record("OSC:LT10:20:FREQ_RETRY_MAX",2120,62,0,0,"OSC:LT10:20:FREQ_RETRY_MAX")
#! Field("OSC:LT10:20:FREQ_RETRY_MAX.VAL",16777215,0,"OSC:LT10:20:FREQ_RETRY_MAX.VAL")
#! Record("OSC:LT10:20:FREQ_TOLERANCE",1020,68,0,0,"OSC:LT10:20:FREQ_TOLERANCE")
#! Field("OSC:LT10:20:FREQ_TOLERANCE.VAL",16777215,1,"OSC:LT10:20:FREQ_TOLERANCE.VAL")
#! Record("OSC:LT10:20:FREQ_TEST",460,814,0,0,"OSC:LT10:20:FREQ_TEST")
#! Field("OSC:LT10:20:FREQ_TEST.VAL",16777215,1,"OSC:LT10:20:FREQ_TEST.VAL")
#! Record("OSC:LT10:20:FREQ_TEST_DECR",720,822,0,0,"OSC:LT10:20:FREQ_TEST_DECR")
#! Field("OSC:LT10:20:FREQ_TEST_DECR.INPA",16777215,0,"OSC:LT10:20:FREQ_TEST_DECR.INPA")
#! Link("OSC:LT10:20:FREQ_TEST_DECR.INPA","OSC:LT10:20:FREQ_TEST.VAL")
#! Field("OSC:LT10:20:FREQ_TEST_DECR.OUT",16777215,0,"OSC:LT10:20:FREQ_TEST_DECR.OUT")
#! Link("OSC:LT10:20:FREQ_TEST_DECR.OUT","OSC:LT10:20:FREQ_TEST.VAL")
#! Record("OSC:LT10:20:FREQ_TEST_INCR",180,822,0,0,"OSC:LT10:20:FREQ_TEST_INCR")
#! Field("OSC:LT10:20:FREQ_TEST_INCR.INPA",16777215,1,"OSC:LT10:20:FREQ_TEST_INCR.INPA")
#! Link("OSC:LT10:20:FREQ_TEST_INCR.INPA","OSC:LT10:20:FREQ_TEST.VAL")
#! Field("OSC:LT10:20:FREQ_TEST_INCR.OUT",16777215,1,"OSC:LT10:20:FREQ_TEST_INCR.OUT")
#! Link("OSC:LT10:20:FREQ_TEST_INCR.OUT","OSC:LT10:20:FREQ_TEST.VAL")
#! Generated by VisualDCT v2.6
#! DBDSTART
#! DBDEND


#
# Vitara Laser Oscillator
# PID Control loop
#
# Required macros:
#DEV			Device prefix for each new PV in this file
#FREQ_MOTOR	PV name of Vitara freq motor
#PHASE_MOTOR	PV name of phase control motor
#RF_LOCK		PV output that enables RF locking
#PIEZO_AMP_IN	Piezo Amp Control voltage readback
#PIEZO_AMP_MON	Piezo Amp Monitor output
# Optional macros:
#   LOCK_ON_VAL, 0.0
#   LOCK_OFF_VAL,5.0 Systems using an analog output as TTL signals can take
#                    the default values for the lock enable values. Otherwise,
#                    define these, probably as 0 and 1 for digital outputs.
#                    Note: On the locking system, the enable line is active
#                    low with a pulldown resistor so that it is enabled when
#                    disconnected.

# Piezo Amplifier Monitor voltage (50mV/V)
record( ai, "OSC:LT10:20:PIEZO_AMP_MON" )
{
  field(DESC, "Piezo Amp Monitor")
  field(INP, "OSC:LT10:20:PD_CH1_PZT_RBCK CP MS")
  field(EGU, "V")
  field(PREC, "3")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PIEZO_AMP_IN" )
{
  field(DESC, "Piezo control voltage")
  field(INP, "OSC:LT10:20:M2_PID_OUTPUT CP MS")
  field(EGU, "V")
  field(PREC, "3")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ao, "OSC:LT10:20:PID_COARSE_TARGET" )
{
  field(DESC, "Target setpoint for PID")
  field(EGU, "rad")
  field(PREC, "3")
  field(VAL, "2.0")
  field(PINI, "YES")
  info(autosaveFields, "VAL DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Phase PID control record
# R/W Fields:
#STPL	Set point CA link
#SMSL	SetPt Mode: closed_loop or supervisory
#VAL		Target  for controlled value (set point )
#FBON	Feedback Output Enable
#INP		DB link for readback of controlled value
#KP		Proportional gain
#KI		Integral     gain
#KD		Derivative   gain
#OUTL	DB link for computed feedback output value
#DRVL	Low  limit on I and OVAL
#DRVH	High limit on I and OVAL
#I		Integral     term
# Read Only Fields
#P		Proportional term
#D		Derivative   term
#CVAL	Controlled value from INP link
#ERR		Current Error (VAL - CVAL )
#OVAL	Output value  (P + I + D )
record( epid, "OSC:LT10:20:PID_COARSE" )
{
  field(DESC, "Piezo motor PID")
  field(SCAN, "10 second")
  field(STPL, "OSC:LT10:20:PID_COARSE_TARGET NPP")
  field(SMSL, "closed_loop")
  field(INP, "OSC:LT10:20:PIEZO_AMP_MON")
  field(OUTL, "OSC:LT10:20:PID_COARSE_OUTPUT PP")
  field(PREC, "4")
  field(DRVH, "0.002")
  field(DRVL, "-0.002")
  field(KP, "-0.001")
  field(EGU, "V")
  field(FLNK, "OSC:LT10:20:PID_COARSE_MOTOR_TGT")
  info(autosaveFields, "SCAN KP KI KD FBON DRVL DRVH VAL OVAL")
}

# Compute new motor position from PID output value
# Updates on each PID process,
# but not when motor RBV changes, so we can
# show where the PID thinks the motor should be
record( calcout, "OSC:LT10:20:PID_COARSE_MOTOR_TGT" )
{
  field(DESC, "Set coarse mtr with PID")
  field(CALC, "A+B")
  field(INPA, "OSC:LT10:20:PID_COARSE.OVAL NPP MS")
  field(INPB, "OSC:LT10:20:M1_MOTR_C.RBV CA MS")
  field(EGU, "mm")
  field(PREC, "4")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC INPB")
}

record( ai, "OSC:LT10:20:PID_COARSE_P" )
{
  field(DESC, "PID Phase PTerm")
  field(INP, "OSC:LT10:20:PID_COARSE.P CP MS")
  field(EGU, "V")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_I" )
{
  field(DESC, "PID Phase ITerm")
  field(INP, "OSC:LT10:20:PID_COARSE.I CP MS")
  field(EGU, "V")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_D" )
{
  field(DESC, "PID Phase DTerm")
  field(INP, "OSC:LT10:20:PID_COARSE.D CP MS")
  field(EGU, "V")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:PID_COARSE_ERR" )
{
  field(DESC, "PID Phase Error")
  field(INP, "OSC:LT10:20:PID_COARSE.ERR CP MS")
  field(EGU, "V")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# Processes when the PID record, OSC:LT10:20:PID_COARSE,
# write's OVAL to this record
# This will only happen when the PID feedback is enabled,
# so this is when we want to write the tgt to the motor
record( ao, "OSC:LT10:20:PID_COARSE_OUTPUT" )
{
  field(DESC, "PID output value")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR PP NMS")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ao, "OSC:LT10:20:PID_COARSE_WRITE_MOTOR" )
{
  field(DESC, "Write PID tgt to motor")
  field(OMSL, "closed_loop")
  field(DOL, "OSC:LT10:20:PID_COARSE_MOTOR_TGT PP MS")
  field(OUT, "OSC:LT10:20:M1_MOTR_C CA NMS")
# PCDS specific SDIS. Don't merge LBLN part
#field( SDIS, "OSC:LT10:20:PID_COARSE_MOTOR_ENABLE NPP NMS" )
  field(SDIS, "OSC:LT10:20:RF_LOCK_ENABLE CPP NMS")
  field(DISV, "0")
}

# PCDS specific calculation. Don't merge LBLN part
#record( calc, "OSC:LT10:20:PID_COARSE_MOTOR_ENABLE" )
#{
#field( DESC, "Enable motor if either system locked" )
#field( INPA, "OSC:LT10:20:PHASE_LOCKED CPP NMS" )
#}
record(calcout, "OSC:LT10:20:PHASE_LOCKED_CALC") {
  field(INPA, "OSC:LT10:20:RF_LOCK_ENABLE CPP MS")
  field(INPB, "OSC:LT10:20:PIEZO_AMP_MON CPP MS")
  field(INPC, "OSC:LT10:20:PIEZO_AMP_MON.LOLO NPP NMS")
  field(INPD, "OSC:LT10:20:PIEZO_AMP_MON.HIHI NPP NMS")
  field(INPE, "OSC:LT10:20:CH1_RF_PWR CPP MS")
  field(INPF, "OSC:LT10:20:CH1_RF_PWR.LOLO NPP NMS")
  field(INPG, "OSC:LT10:20:CH1_DIODE_PWR CPP MS")
  field(INPH, "OSC:LT10:20:CH1_DIODE_PWR.LOLO NPP NMS")
  field(INPI, "OSC:LT10:20:FREQ_ERR PP MS")
  field(INPJ, "OSC:LT10:20:FREQ_ERR.HIHI NPP NMS")
  field(INPK, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_STD PP MS")
  field(INPL, "OSC:LT10:20:CH1_CALC_PHASE_LAST_60_STD.HIHI NPP NMS")
  field(CALC, "A=1&&B>C&&B<D&&E>F&&G>H&&ABS(I)<J&&K<L")
  field(OUT, "OSC:LT10:20:PHASE_LOCKED PP MS")
  field(PREC, "4")
}

record( bo, "OSC:LT10:20:PHASE_LOCKED" )
{
  field(DESC, "Laser timing locked")
  field(ZNAM, "Unlocked")
  field(ZSV, "MAJOR")
  field(ONAM, "Locked")
  field(OSV, "NO_ALARM")
  field(PINI, "YES")
}

# RF_LOCK_ENABLE is same as FACET PID_MODE
record( bo, "OSC:LT10:20:RF_LOCK_ENABLE" )
{
  field(DESC, "RF Locking Enabled")
  field(ZNAM, "Disabled")
  field(ZSV, "MINOR")
  field(ONAM, "Enabled")
  field(OSV, "NO_ALARM")
  field(FLNK, "OSC:LT10:20:RF_LOCK_ENABLE_CALC PP NMS" )
  field(PINI, "YES")
  field(SCAN, "1 second")
  info(autosaveFields, "VAL")
}

record( calcout, "OSC:LT10:20:RF_LOCK_ENABLE_CALC" )
{
  field(INPA, "OSC:LT10:20:RF_LOCK_ENABLE NPP NMS")
  field(CALC, "A ? 0.0 : 5.0")
  field(OUT, "OSC:LT10:20:RF_LOCK_AO CA NMS")
}

record( ai, "OSC:LT10:20:PHASE_MOTOR_POS" )
{
  field(DESC, "Cur phase motor pos")
  field(INP, "OSC:LT10:20:M1_MOTR_IQ.RBV CP MS")
  field(EGU, "ps")
  field(PREC, "6")
  info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

#! Further lines contain data used by VisualDCT
#! View(54,6,1.0)
#! Record("OSC:LT10:20:PIEZO_AMP_MON",1480,48,0,0,"OSC:LT10:20:PIEZO_AMP_MON")
#! Field("OSC:LT10:20:PIEZO_AMP_MON.INP",16777215,1,"OSC:LT10:20:PIEZO_AMP_MON.INP")
#! Field("OSC:LT10:20:PIEZO_AMP_MON.VAL",16777215,0,"OSC:LT10:20:PIEZO_AMP_MON.VAL")
#! Field("OSC:LT10:20:PIEZO_AMP_MON.LOLO",16777215,0,"OSC:LT10:20:PIEZO_AMP_MON.LOLO")
#! Field("OSC:LT10:20:PIEZO_AMP_MON.HIHI",16777215,0,"OSC:LT10:20:PIEZO_AMP_MON.HIHI")
#! Record("OSC:LT10:20:PIEZO_AMP_IN",1960,428,0,0,"OSC:LT10:20:PIEZO_AMP_IN")
#! Field("OSC:LT10:20:PIEZO_AMP_IN.INP",16777215,1,"OSC:LT10:20:PIEZO_AMP_IN.INP")
#! Record("OSC:LT10:20:PID_COARSE_TARGET",340,14,0,0,"OSC:LT10:20:PID_COARSE_TARGET")
#! Field("OSC:LT10:20:PID_COARSE_TARGET.VAL",16777215,0,"OSC:LT10:20:PID_COARSE_TARGET.VAL")
#! Record("OSC:LT10:20:PID_COARSE",580,17,0,0,"OSC:LT10:20:PID_COARSE")
#! Field("OSC:LT10:20:PID_COARSE.STPL",16777215,0,"OSC:LT10:20:PID_COARSE.STPL")
#! Link("OSC:LT10:20:PID_COARSE.STPL","OSC:LT10:20:PID_COARSE_TARGET.VAL")
#! Field("OSC:LT10:20:PID_COARSE.INP",16777215,1,"OSC:LT10:20:PID_COARSE.INP")
#! Link("OSC:LT10:20:PID_COARSE.INP","OSC:LT10:20:PIEZO_AMP_MON.VAL")
#! Field("OSC:LT10:20:PID_COARSE.OUTL",16777215,1,"OSC:LT10:20:PID_COARSE.OUTL")
#! Link("OSC:LT10:20:PID_COARSE.OUTL","OSC:LT10:20:PID_COARSE_OUTPUT.VAL")
#! Field("OSC:LT10:20:PID_COARSE.FLNK",16777215,1,"OSC:LT10:20:PID_COARSE.FLNK")
#! Link("OSC:LT10:20:PID_COARSE.FLNK","OSC:LT10:20:PID_COARSE_MOTOR_TGT")
#! Field("OSC:LT10:20:PID_COARSE.OVAL",16777215,1,"OSC:LT10:20:PID_COARSE.OVAL")
#! Field("OSC:LT10:20:PID_COARSE.P",16777215,0,"OSC:LT10:20:PID_COARSE.P")
#! Field("OSC:LT10:20:PID_COARSE.I",16777215,0,"OSC:LT10:20:PID_COARSE.I")
#! Field("OSC:LT10:20:PID_COARSE.D",16777215,0,"OSC:LT10:20:PID_COARSE.D")
#! Field("OSC:LT10:20:PID_COARSE.ERR",16777215,1,"OSC:LT10:20:PID_COARSE.ERR")
#! Record("OSC:LT10:20:PID_COARSE_MOTOR_TGT",1100,300,0,0,"OSC:LT10:20:PID_COARSE_MOTOR_TGT")
#! Field("OSC:LT10:20:PID_COARSE_MOTOR_TGT.INPA",16777215,0,"OSC:LT10:20:PID_COARSE_MOTOR_TGT.INPA")
#! Link("OSC:LT10:20:PID_COARSE_MOTOR_TGT.INPA","OSC:LT10:20:PID_COARSE.OVAL")
#! Field("OSC:LT10:20:PID_COARSE_MOTOR_TGT.INPB",16777215,1,"OSC:LT10:20:PID_COARSE_MOTOR_TGT.INPB")
#! Field("OSC:LT10:20:PID_COARSE_MOTOR_TGT.VAL",16777215,0,"OSC:LT10:20:PID_COARSE_MOTOR_TGT.VAL")
#! Record("OSC:LT10:20:PID_COARSE_P",280,282,0,0,"OSC:LT10:20:PID_COARSE_P")
#! Field("OSC:LT10:20:PID_COARSE_P.INP",16777215,1,"OSC:LT10:20:PID_COARSE_P.INP")
#! Link("OSC:LT10:20:PID_COARSE_P.INP","OSC:LT10:20:PID_COARSE.P")
#! Record("OSC:LT10:20:PID_COARSE_I",280,402,0,0,"OSC:LT10:20:PID_COARSE_I")
#! Field("OSC:LT10:20:PID_COARSE_I.INP",16777215,1,"OSC:LT10:20:PID_COARSE_I.INP")
#! Link("OSC:LT10:20:PID_COARSE_I.INP","OSC:LT10:20:PID_COARSE.I")
#! Record("OSC:LT10:20:PID_COARSE_D",280,502,0,0,"OSC:LT10:20:PID_COARSE_D")
#! Field("OSC:LT10:20:PID_COARSE_D.INP",16777215,1,"OSC:LT10:20:PID_COARSE_D.INP")
#! Link("OSC:LT10:20:PID_COARSE_D.INP","OSC:LT10:20:PID_COARSE.D")
#! Record("OSC:LT10:20:PID_COARSE_ERR",300,622,0,0,"OSC:LT10:20:PID_COARSE_ERR")
#! Field("OSC:LT10:20:PID_COARSE_ERR.INP",16777215,1,"OSC:LT10:20:PID_COARSE_ERR.INP")
#! Link("OSC:LT10:20:PID_COARSE_ERR.INP","OSC:LT10:20:PID_COARSE.ERR")
#! Record("OSC:LT10:20:PID_COARSE_OUTPUT",860,8,0,0,"OSC:LT10:20:PID_COARSE_OUTPUT")
#! Field("OSC:LT10:20:PID_COARSE_OUTPUT.VAL",16777215,0,"OSC:LT10:20:PID_COARSE_OUTPUT.VAL")
#! Field("OSC:LT10:20:PID_COARSE_OUTPUT.FLNK",16777215,1,"OSC:LT10:20:PID_COARSE_OUTPUT.FLNK")
#! Link("OSC:LT10:20:PID_COARSE_OUTPUT.FLNK","OSC:LT10:20:PID_COARSE_WRITE_MOTOR")
#! Record("OSC:LT10:20:PID_COARSE_WRITE_MOTOR",1100,40,0,1,"OSC:LT10:20:PID_COARSE_WRITE_MOTOR")
#! Field("OSC:LT10:20:PID_COARSE_WRITE_MOTOR.DOL",16777215,0,"OSC:LT10:20:PID_COARSE_WRITE_MOTOR.DOL")
#! Link("OSC:LT10:20:PID_COARSE_WRITE_MOTOR.DOL","OSC:LT10:20:PID_COARSE_MOTOR_TGT.VAL")
#! Field("OSC:LT10:20:PID_COARSE_WRITE_MOTOR.OUT",16777215,1,"OSC:LT10:20:PID_COARSE_WRITE_MOTOR.OUT")
#! Field("OSC:LT10:20:PID_COARSE_WRITE_MOTOR.SDIS",16777215,1,"OSC:LT10:20:PID_COARSE_WRITE_MOTOR.SDIS")
#! Link("OSC:LT10:20:PID_COARSE_WRITE_MOTOR.SDIS","OSC:LT10:20:PHASE_LOCKED.VAL")
#! Record("OSC:LT10:20:PHASE_LOCKED_CALC",1720,-25,0,0,"OSC:LT10:20:PHASE_LOCKED_CALC")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPA",16777215,1,"OSC:LT10:20:PHASE_LOCKED_CALC.INPA")
#! Link("OSC:LT10:20:PHASE_LOCKED_CALC.INPA","OSC:LT10:20:RF_LOCK_ENABLE.VAL")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPB",16777215,0,"OSC:LT10:20:PHASE_LOCKED_CALC.INPB")
#! Link("OSC:LT10:20:PHASE_LOCKED_CALC.INPB","OSC:LT10:20:PIEZO_AMP_MON.VAL")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPC",16777215,0,"OSC:LT10:20:PHASE_LOCKED_CALC.INPC")
#! Link("OSC:LT10:20:PHASE_LOCKED_CALC.INPC","OSC:LT10:20:PIEZO_AMP_MON.LOLO")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPD",16777215,0,"OSC:LT10:20:PHASE_LOCKED_CALC.INPD")
#! Link("OSC:LT10:20:PHASE_LOCKED_CALC.INPD","OSC:LT10:20:PIEZO_AMP_MON.HIHI")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPE",16777215,1,"OSC:LT10:20:PHASE_LOCKED_CALC.INPE")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPF",16777215,1,"OSC:LT10:20:PHASE_LOCKED_CALC.INPF")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPG",16777215,1,"OSC:LT10:20:PHASE_LOCKED_CALC.INPG")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPH",16777215,1,"OSC:LT10:20:PHASE_LOCKED_CALC.INPH")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPI",16777215,1,"OSC:LT10:20:PHASE_LOCKED_CALC.INPI")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPJ",16777215,1,"OSC:LT10:20:PHASE_LOCKED_CALC.INPJ")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPK",16777215,1,"OSC:LT10:20:PHASE_LOCKED_CALC.INPK")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.INPL",16777215,1,"OSC:LT10:20:PHASE_LOCKED_CALC.INPL")
#! Field("OSC:LT10:20:PHASE_LOCKED_CALC.OUT",16777215,0,"OSC:LT10:20:PHASE_LOCKED_CALC.OUT")
#! Link("OSC:LT10:20:PHASE_LOCKED_CALC.OUT","OSC:LT10:20:PHASE_LOCKED.VAL")
#! Record("OSC:LT10:20:PHASE_LOCKED",1460,340,0,0,"OSC:LT10:20:PHASE_LOCKED")
#! Field("OSC:LT10:20:PHASE_LOCKED.VAL",16777215,0,"OSC:LT10:20:PHASE_LOCKED.VAL")
#! Record("OSC:LT10:20:RF_LOCK_ENABLE",1960,46,0,0,"OSC:LT10:20:RF_LOCK_ENABLE")
#! Field("OSC:LT10:20:RF_LOCK_ENABLE.VAL",16777215,1,"OSC:LT10:20:RF_LOCK_ENABLE.VAL")
#! Field("OSC:LT10:20:RF_LOCK_ENABLE.OUT",16777215,1,"OSC:LT10:20:RF_LOCK_ENABLE.OUT")
#! Record("OSC:LT10:20:RF_LOCK_ENABLE_CALC",2200,22,0,0,"OSC:LT10:20:RF_LOCK_ENABLE_CALC")
#! Field("OSC:LT10:20:RF_LOCK_ENABLE_CALC.INPA",16777215,0,"OSC:LT10:20:RF_LOCK_ENABLE_CALC.INPA")
#! Link("OSC:LT10:20:RF_LOCK_ENABLE_CALC.INPA","OSC:LT10:20:RF_LOCK_ENABLE.VAL")
#! Field("OSC:LT10:20:RF_LOCK_ENABLE_CALC.OUT",16777215,1,"OSC:LT10:20:RF_LOCK_ENABLE_CALC.OUT")
#! Record("OSC:LT10:20:PHASE_MOTOR_POS",1960,268,0,0,"OSC:LT10:20:PHASE_MOTOR_POS")
#! Field("OSC:LT10:20:PHASE_MOTOR_POS.INP",16777215,1,"OSC:LT10:20:PHASE_MOTOR_POS.INP")
#
# vitaraRFChan.template
#
# Required Macros:
#	CH				PV prefix for this RF channel
#	CH_DIODE		Analog Input  for RF Channel Diode Power
#	CH_GAIN			Analog Output for RF Channel Gain
#	CH_PHASE		Analog Input  for RF Channel Phase
#	CH_PHASE_X30	Analog Input  for RF Channel Phase times 30
#	CH_RF_PWR		Analog Input  for RF Channel RF Power

record( ai, "OSC:LT10:20:CH1_DIODE_PWR" )
{
	field( DESC, "Diode Power" )
	field( INP,  "OSC:LT10:20:PD_CH1_DIODE_PWR_RBCK CP MS" )
	field( EGU,  "V" )
	field( PREC, "3" )
	field( LOW,  "1.75" )
	field( LSV,  "MINOR" )
	field( LOLO, "1.5" )
	field( LLSV, "MAJOR" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_RF_PWR" )
{
	field( DESC, "RF Power" )
	field( INP,  "OSC:LT10:20:PD_CH1_RF_PWR_RBCK CP MS" )
	field( EGU,  "V" )
	field( PREC, "3" )
	field( LOW,  "1.25" )
	field( LSV,  "MINOR" )
	field( LOLO, "1.0" )
	field( LLSV, "MAJOR" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE" )
{
	field( DESC, "RF Phase" )
	field( INP,  "OSC:LT10:20:PD_CH1_PH_RBCK CP MS" )
	field( EGU,  "V" )
	field( PREC, "3" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( ai, "OSC:LT10:20:CH1_PHASE_X30" )
{
	field( DESC, "RF Phase X30" )
	field( INP,  "OSC:LT10:20:PD_CH1_PH_X30_RBCK CP MS" )
	field( EGU,  "V" )
	field( PREC, "3" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

record( bo, "OSC:LT10:20:CH1_LockBoardType" )
{
	field( DESC, "Locker type" )
	field( VAL,	 "0" )
	field( ZNAM, "Analog" )
	field( ONAM, "Digital" )
	field( PINI, "YES" )
	info(autosaveFields, "VAL")
}

record( calc, "OSC:LT10:20:CH1_CALC_PHASE" )
{
	field( DESC, "Scaled phase calculation" )
	field( INPA, "OSC:LT10:20:CH1_PHASE_X30 CP" )
	field( INPB, "OSC:LT10:20:CH1_RF_PWR NPP" )
	field( INPC, "OSC:LT10:20:CH1_DIODE_PWR NPP" )
	field( INPD, "OSC:LT10:20:CH1_LockBoardType NPP" )
	field( CALC, "D?(A*1000):((B*C)?(1000*A/SQR(B*C/2)):0)" )
	field( EGU,  "ps" )
	field( PREC, "3" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC")
}

# In LCLS, this is an IP231 output in the Laser app on ioc-lr20-ls01. 
# So if SYS is defined as SYS0, change the PV name by tacking "_WRAPPER"
# on to the end.
record( ao, "OSC:LT10:20:CH1_FEEDBACK_GAIN" )
{
	field( DESC, "RF Feedback Gain" )
	field( OUT,  "OSC:LT10:20:CH1_FEEDBACK_GAIN CA MS" )
	field( EGU,  "V" )
	field( VAL,  "10.0" )
	field( PREC, "3" )
    field( PINI, "YES" )
	info(autosaveFields, "DESC EGU HHSV HIGH HIHI HSV LLSV LOLO LOW LSV PREC VAL")
}

record(motor,"OSC:LT10:20:M1_MOTR_IQ")
{
	field(DESC,"MForce IQ_CTRL")
	field(DTYP,"asynMotor")
	field(DIR,"Neg")
	field(VELO,"6827.72")
	field(VBAS,"525.209")
	field(ACCL,"0.01")
	field(BDST,"0")
	field(BVEL,"525.209")
	field(BACC,"2.0")
	field(OUT,"@asyn(IMS1,0)")
	field(MRES,"0.0160291")
	field(PREC,"4")
	field(EGU,"ps")
	field(DHLM,"36000")
	field(DLLM,"-36000")
	field(INIT,"")
	field(TWV,"1")
}

