#
# Template for generating aSub records which accumulate
# a history of the specified PV over the specified time period.
#
#	Macros:
#		PV			- Name of PV to track
#		PERIOD		- Time period over which to retain history, in seconds
#						If zero, each sample gets shifted into the buffer
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)DIODE_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)DIODE_PWR_LAST_N PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)DIODE_PWR_LAST_N")
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)DIODE_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)DIODE_PWR_LAST_N:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)DIODE_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)DIODE_PWR_1MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)DIODE_PWR_1MIN")
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)DIODE_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)DIODE_PWR_1MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)DIODE_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)DIODE_PWR_6MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)DIODE_PWR_6MIN")
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)DIODE_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)DIODE_PWR_6MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)DIODE_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)DIODE_PWR_30MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)DIODE_PWR_30MIN")
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)DIODE_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)DIODE_PWR_30MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)DIODE_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)DIODE_PWR_1HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)DIODE_PWR_1HR")
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)DIODE_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)DIODE_PWR_1HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)DIODE_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)DIODE_PWR_6HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)DIODE_PWR_6HR")
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)DIODE_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)DIODE_PWR_6HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)DIODE_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)DIODE_PWR_24HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)DIODE_PWR_24HR")
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)DIODE_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)DIODE_PWR_24HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)DIODE_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)DIODE_PWR_3DAY PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)DIODE_PWR_3DAY")
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)DIODE_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)DIODE_PWR_3DAY:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)DIODE_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)DIODE_PWR_WEEK PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)DIODE_PWR_WEEK")
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)DIODE_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)DIODE_PWR_WEEK:X-AXIS PP" )
}

record(waveform, "$(CH)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, "$(CH)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, "$(CH)DIODE_PWR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)DIODE_PWR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)DIODE_PWR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)DIODE_PWR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)DIODE_PWR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)DIODE_PWR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)DIODE_PWR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)DIODE_PWR_LAST_N_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)DIODE_PWR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)DIODE_PWR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)DIODE_PWR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)DIODE_PWR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)DIODE_PWR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)DIODE_PWR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)DIODE_PWR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)DIODE_PWR_1MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)DIODE_PWR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)DIODE_PWR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)DIODE_PWR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)DIODE_PWR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)DIODE_PWR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)DIODE_PWR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)DIODE_PWR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)DIODE_PWR_6MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)DIODE_PWR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)DIODE_PWR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)DIODE_PWR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)DIODE_PWR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)DIODE_PWR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)DIODE_PWR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)DIODE_PWR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)DIODE_PWR_30MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)DIODE_PWR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)DIODE_PWR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)DIODE_PWR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)DIODE_PWR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)DIODE_PWR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)DIODE_PWR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)DIODE_PWR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)DIODE_PWR_1HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)DIODE_PWR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)DIODE_PWR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)DIODE_PWR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)DIODE_PWR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)DIODE_PWR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)DIODE_PWR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)DIODE_PWR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)DIODE_PWR_6HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)DIODE_PWR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)DIODE_PWR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)DIODE_PWR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)DIODE_PWR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)DIODE_PWR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)DIODE_PWR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)DIODE_PWR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)DIODE_PWR_24HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)DIODE_PWR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)DIODE_PWR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)DIODE_PWR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)DIODE_PWR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)DIODE_PWR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)DIODE_PWR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)DIODE_PWR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)DIODE_PWR_3DAY_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)DIODE_PWR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)DIODE_PWR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)DIODE_PWR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)DIODE_PWR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)DIODE_PWR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)DIODE_PWR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)DIODE_PWR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)DIODE_PWR_WEEK_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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( "$(CH)DIODE_PWR_LAST_N_MAX",    "$(CH)DIODE_PWR_MAX" )
alias( "$(CH)DIODE_PWR_LAST_N_AVG",    "$(CH)DIODE_PWR_AVG" )
alias( "$(CH)DIODE_PWR_LAST_N_MIN",    "$(CH)DIODE_PWR_MIN" )
alias( "$(CH)DIODE_PWR_LAST_N_RMS",    "$(CH)DIODE_PWR_RMS" )
alias( "$(CH)DIODE_PWR_LAST_N_STD",    "$(CH)DIODE_PWR_STD" )
alias( "$(CH)DIODE_PWR_LAST_N_SLOPE",  "$(CH)DIODE_PWR_SLOPE" )
alias( "$(CH)DIODE_PWR_LAST_N_OFFSET", "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)FEEDBACK_GAIN CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_LAST_N PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)FEEDBACK_GAIN_LAST_N")
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)FEEDBACK_GAIN.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)FEEDBACK_GAIN_LAST_N:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)FEEDBACK_GAIN CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_1MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)FEEDBACK_GAIN_1MIN")
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)FEEDBACK_GAIN.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)FEEDBACK_GAIN_1MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)FEEDBACK_GAIN CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_6MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)FEEDBACK_GAIN_6MIN")
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)FEEDBACK_GAIN.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)FEEDBACK_GAIN_6MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)FEEDBACK_GAIN CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_30MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)FEEDBACK_GAIN_30MIN")
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)FEEDBACK_GAIN.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)FEEDBACK_GAIN_30MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)FEEDBACK_GAIN CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_1HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)FEEDBACK_GAIN_1HR")
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)FEEDBACK_GAIN.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)FEEDBACK_GAIN_1HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)FEEDBACK_GAIN CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_6HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)FEEDBACK_GAIN_6HR")
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)FEEDBACK_GAIN.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)FEEDBACK_GAIN_6HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)FEEDBACK_GAIN CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_24HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)FEEDBACK_GAIN_24HR")
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)FEEDBACK_GAIN.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)FEEDBACK_GAIN_24HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)FEEDBACK_GAIN CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_3DAY PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)FEEDBACK_GAIN_3DAY")
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)FEEDBACK_GAIN.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)FEEDBACK_GAIN_3DAY:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)FEEDBACK_GAIN CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_WEEK PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)FEEDBACK_GAIN_WEEK")
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)FEEDBACK_GAIN.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)FEEDBACK_GAIN_WEEK:X-AXIS PP" )
}

record(waveform, "$(CH)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, "$(CH)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, "$(CH)FEEDBACK_GAIN_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)FEEDBACK_GAIN_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)FEEDBACK_GAIN_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)FEEDBACK_GAIN_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)FEEDBACK_GAIN_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)FEEDBACK_GAIN_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)FEEDBACK_GAIN_LAST_N_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)FEEDBACK_GAIN_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)FEEDBACK_GAIN_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)FEEDBACK_GAIN_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)FEEDBACK_GAIN_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)FEEDBACK_GAIN_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)FEEDBACK_GAIN_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)FEEDBACK_GAIN_1MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)FEEDBACK_GAIN_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)FEEDBACK_GAIN_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)FEEDBACK_GAIN_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)FEEDBACK_GAIN_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)FEEDBACK_GAIN_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)FEEDBACK_GAIN_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)FEEDBACK_GAIN_6MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)FEEDBACK_GAIN_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)FEEDBACK_GAIN_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)FEEDBACK_GAIN_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)FEEDBACK_GAIN_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)FEEDBACK_GAIN_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)FEEDBACK_GAIN_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)FEEDBACK_GAIN_30MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)FEEDBACK_GAIN_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)FEEDBACK_GAIN_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)FEEDBACK_GAIN_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)FEEDBACK_GAIN_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)FEEDBACK_GAIN_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)FEEDBACK_GAIN_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)FEEDBACK_GAIN_1HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)FEEDBACK_GAIN_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)FEEDBACK_GAIN_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)FEEDBACK_GAIN_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)FEEDBACK_GAIN_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)FEEDBACK_GAIN_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)FEEDBACK_GAIN_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)FEEDBACK_GAIN_6HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)FEEDBACK_GAIN_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)FEEDBACK_GAIN_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)FEEDBACK_GAIN_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)FEEDBACK_GAIN_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)FEEDBACK_GAIN_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)FEEDBACK_GAIN_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)FEEDBACK_GAIN_24HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)FEEDBACK_GAIN_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)FEEDBACK_GAIN_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)FEEDBACK_GAIN_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)FEEDBACK_GAIN_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)FEEDBACK_GAIN_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)FEEDBACK_GAIN_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)FEEDBACK_GAIN_3DAY_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)FEEDBACK_GAIN_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)FEEDBACK_GAIN_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)FEEDBACK_GAIN_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)FEEDBACK_GAIN_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)FEEDBACK_GAIN_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)FEEDBACK_GAIN_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)FEEDBACK_GAIN_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)FEEDBACK_GAIN_WEEK_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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( "$(CH)FEEDBACK_GAIN_LAST_N_MAX",    "$(CH)FEEDBACK_GAIN_MAX" )
alias( "$(CH)FEEDBACK_GAIN_LAST_N_AVG",    "$(CH)FEEDBACK_GAIN_AVG" )
alias( "$(CH)FEEDBACK_GAIN_LAST_N_MIN",    "$(CH)FEEDBACK_GAIN_MIN" )
alias( "$(CH)FEEDBACK_GAIN_LAST_N_RMS",    "$(CH)FEEDBACK_GAIN_RMS" )
alias( "$(CH)FEEDBACK_GAIN_LAST_N_STD",    "$(CH)FEEDBACK_GAIN_STD" )
alias( "$(CH)FEEDBACK_GAIN_LAST_N_SLOPE",  "$(CH)FEEDBACK_GAIN_SLOPE" )
alias( "$(CH)FEEDBACK_GAIN_LAST_N_OFFSET", "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_LAST_N PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_LAST_N")
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_LAST_N:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_1MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_1MIN")
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_1MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_6MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_6MIN")
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_6MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_30MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_30MIN")
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_30MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_1HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_1HR")
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_1HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_6HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_6HR")
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_6HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_24HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_24HR")
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_24HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_3DAY PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_3DAY")
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_3DAY:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_WEEK PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_WEEK")
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_WEEK:X-AXIS PP" )
}

record(waveform, "$(CH)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, "$(CH)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, "$(CH)PHASE_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_LAST_N_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_1MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_6MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_30MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_1HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_6HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_24HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_3DAY_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_WEEK_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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( "$(CH)PHASE_LAST_N_MAX",    "$(CH)PHASE_MAX" )
alias( "$(CH)PHASE_LAST_N_AVG",    "$(CH)PHASE_AVG" )
alias( "$(CH)PHASE_LAST_N_MIN",    "$(CH)PHASE_MIN" )
alias( "$(CH)PHASE_LAST_N_RMS",    "$(CH)PHASE_RMS" )
alias( "$(CH)PHASE_LAST_N_STD",    "$(CH)PHASE_STD" )
alias( "$(CH)PHASE_LAST_N_SLOPE",  "$(CH)PHASE_SLOPE" )
alias( "$(CH)PHASE_LAST_N_OFFSET", "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE_X30 CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_X30_LAST_N PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_X30_LAST_N")
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE_X30.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_X30_LAST_N:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE_X30 CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_X30_1MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_X30_1MIN")
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE_X30.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_X30_1MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE_X30 CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_X30_6MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_X30_6MIN")
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE_X30.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_X30_6MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE_X30 CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_X30_30MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_X30_30MIN")
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE_X30.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_X30_30MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE_X30 CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_X30_1HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_X30_1HR")
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE_X30.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_X30_1HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE_X30 CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_X30_6HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_X30_6HR")
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE_X30.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_X30_6HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE_X30 CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_X30_24HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_X30_24HR")
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE_X30.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_X30_24HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE_X30 CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_X30_3DAY PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_X30_3DAY")
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE_X30.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_X30_3DAY:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)PHASE_X30 CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)PHASE_X30_WEEK PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)PHASE_X30_WEEK")
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)PHASE_X30.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)PHASE_X30_WEEK:X-AXIS PP" )
}

record(waveform, "$(CH)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, "$(CH)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, "$(CH)PHASE_X30_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_X30_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_X30_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_X30_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_X30_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_X30_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_X30_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_X30_LAST_N_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_X30_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_X30_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_X30_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_X30_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_X30_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_X30_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_X30_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_X30_1MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_X30_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_X30_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_X30_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_X30_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_X30_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_X30_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_X30_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_X30_6MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_X30_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_X30_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_X30_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_X30_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_X30_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_X30_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_X30_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_X30_30MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_X30_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_X30_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_X30_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_X30_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_X30_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_X30_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_X30_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_X30_1HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_X30_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_X30_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_X30_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_X30_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_X30_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_X30_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_X30_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_X30_6HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_X30_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_X30_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_X30_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_X30_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_X30_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_X30_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_X30_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_X30_24HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_X30_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_X30_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_X30_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_X30_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_X30_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_X30_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_X30_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_X30_3DAY_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)PHASE_X30_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)PHASE_X30_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)PHASE_X30_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)PHASE_X30_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)PHASE_X30_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)PHASE_X30_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)PHASE_X30_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)PHASE_X30_WEEK_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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( "$(CH)PHASE_X30_LAST_N_MAX",    "$(CH)PHASE_X30_MAX" )
alias( "$(CH)PHASE_X30_LAST_N_AVG",    "$(CH)PHASE_X30_AVG" )
alias( "$(CH)PHASE_X30_LAST_N_MIN",    "$(CH)PHASE_X30_MIN" )
alias( "$(CH)PHASE_X30_LAST_N_RMS",    "$(CH)PHASE_X30_RMS" )
alias( "$(CH)PHASE_X30_LAST_N_STD",    "$(CH)PHASE_X30_STD" )
alias( "$(CH)PHASE_X30_LAST_N_SLOPE",  "$(CH)PHASE_X30_SLOPE" )
alias( "$(CH)PHASE_X30_LAST_N_OFFSET", "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)RF_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)RF_PWR_LAST_N PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)RF_PWR_LAST_N")
{
    field( DESC, "LAST_N Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)RF_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)RF_PWR_LAST_N:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)RF_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)RF_PWR_1MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)RF_PWR_1MIN")
{
    field( DESC, "1MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)RF_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)RF_PWR_1MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)RF_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)RF_PWR_6MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)RF_PWR_6MIN")
{
    field( DESC, "6MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)RF_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)RF_PWR_6MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)RF_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)RF_PWR_30MIN PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)RF_PWR_30MIN")
{
    field( DESC, "30MIN Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)RF_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)RF_PWR_30MIN:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)RF_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)RF_PWR_1HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)RF_PWR_1HR")
{
    field( DESC, "1HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)RF_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)RF_PWR_1HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)RF_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)RF_PWR_6HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)RF_PWR_6HR")
{
    field( DESC, "6HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)RF_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)RF_PWR_6HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)RF_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)RF_PWR_24HR PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)RF_PWR_24HR")
{
    field( DESC, "24HR Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)RF_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)RF_PWR_24HR:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)RF_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)RF_PWR_3DAY PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)RF_PWR_3DAY")
{
    field( DESC, "3DAY Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)RF_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)RF_PWR_3DAY:X-AXIS PP" )
}

record(waveform, "$(CH)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
#		N_SAMPLES	- Number of samples to keep, Output waveform's NELEM
#						Defaults to 300
#		EGU			- EGU for sample data, defaults to ""
#		X_EGU		- Units to display on the time axis
#		S_PER_X_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 $(CH)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
#		T	- unsigned integer time period in seconds
#	Outputs:
#		A	- Array of double's containing samples of A
#				taken over the last T seconds.
#
record( aSub, "$(CH)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( FTA,  "DOUBLE" )
	field( NOA,  1 )
	field( INPA, "$(CH)RF_PWR CP NMS" )

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

	field( FTVA, "DOUBLE" )
	field( NOVA, 300 )
	field( OUTA, "$(CH)RF_PWR_WEEK PP" )
	info( autosaveFields, "VALA NEA" )

}

record( waveform, "$(CH)RF_PWR_WEEK")
{
    field( DESC, "WEEK Hist" )
	field( FTVL, "DOUBLE" )
	field( EGU,  "V" )
	field( NELM, 300 )
	field( TSEL, "$(CH)RF_PWR.TIME" )
	info(autosaveFields, "VAL")
}

# Create an array of time coordinates in the specified units
record(acalcout, "$(CH)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,  "$(CH)RF_PWR_WEEK:X-AXIS PP" )
}

record(waveform, "$(CH)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, "$(CH)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, "$(CH)RF_PWR_LAST_N CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)RF_PWR_LAST_N_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)RF_PWR_LAST_N_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)RF_PWR_LAST_N_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)RF_PWR_LAST_N_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)RF_PWR_LAST_N_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)RF_PWR_LAST_N_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)RF_PWR_LAST_N_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)RF_PWR_1MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)RF_PWR_1MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)RF_PWR_1MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)RF_PWR_1MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)RF_PWR_1MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)RF_PWR_1MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)RF_PWR_1MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)RF_PWR_1MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)RF_PWR_6MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)RF_PWR_6MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)RF_PWR_6MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)RF_PWR_6MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)RF_PWR_6MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)RF_PWR_6MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)RF_PWR_6MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)RF_PWR_6MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)RF_PWR_30MIN CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)RF_PWR_30MIN_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)RF_PWR_30MIN_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)RF_PWR_30MIN_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)RF_PWR_30MIN_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)RF_PWR_30MIN_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)RF_PWR_30MIN_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)RF_PWR_30MIN_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)RF_PWR_1HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)RF_PWR_1HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)RF_PWR_1HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)RF_PWR_1HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)RF_PWR_1HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)RF_PWR_1HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)RF_PWR_1HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)RF_PWR_1HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)RF_PWR_6HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)RF_PWR_6HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)RF_PWR_6HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)RF_PWR_6HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)RF_PWR_6HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)RF_PWR_6HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)RF_PWR_6HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)RF_PWR_6HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)RF_PWR_24HR CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)RF_PWR_24HR_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)RF_PWR_24HR_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)RF_PWR_24HR_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)RF_PWR_24HR_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)RF_PWR_24HR_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)RF_PWR_24HR_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)RF_PWR_24HR_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)RF_PWR_3DAY CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)RF_PWR_3DAY_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)RF_PWR_3DAY_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)RF_PWR_3DAY_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)RF_PWR_3DAY_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)RF_PWR_3DAY_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)RF_PWR_3DAY_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)RF_PWR_3DAY_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)RF_PWR_WEEK CPP NMS" )

	field( FTVA, "DOUBLE" )
	field( NOVA, 1 )
	field( OUTA, "$(CH)RF_PWR_WEEK_RMS PP" )

	field( FTVB, "DOUBLE" )
	field( NOVB, 1 )
	field( OUTB, "$(CH)RF_PWR_WEEK_MAX PP" )

	field( FTVC, "DOUBLE" )
	field( NOVC, 1 )
	field( OUTC, "$(CH)RF_PWR_WEEK_MIN PP" )

	field( FTVD, "DOUBLE" )
	field( NOVD, 1 )
	field( OUTD, "$(CH)RF_PWR_WEEK_AVG PP" )

	field( FTVE, "DOUBLE" )
	field( NOVE, 1 )
	field( OUTE, "$(CH)RF_PWR_WEEK_STD PP" )

	field( FTVF, "DOUBLE" )
	field( NOVF, 1 )
	field( OUTF, "$(CH)RF_PWR_WEEK_SLOPE PP" )

	field( FTVG, "DOUBLE" )
	field( NOVG, 1 )
	field( OUTG, "$(CH)RF_PWR_WEEK_OFFSET PP" )
}

record( ai, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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, "$(CH)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( "$(CH)RF_PWR_LAST_N_MAX",    "$(CH)RF_PWR_MAX" )
alias( "$(CH)RF_PWR_LAST_N_AVG",    "$(CH)RF_PWR_AVG" )
alias( "$(CH)RF_PWR_LAST_N_MIN",    "$(CH)RF_PWR_MIN" )
alias( "$(CH)RF_PWR_LAST_N_RMS",    "$(CH)RF_PWR_RMS" )
alias( "$(CH)RF_PWR_LAST_N_STD",    "$(CH)RF_PWR_STD" )
alias( "$(CH)RF_PWR_LAST_N_SLOPE",  "$(CH)RF_PWR_SLOPE" )
alias( "$(CH)RF_PWR_LAST_N_OFFSET", "$(CH)RF_PWR_OFFSET" )
