#*************************************************************************
# Copyright (c) 2007 UChicago Argonne LLC, as Operator of Argonne
#     National Laboratory.
# Copyright (c) 2002 The Regents of the University of California, as
#     Operator of Los Alamos National Laboratory.
# EPICS BASE is distributed subject to a Software License Agreement found
# in file LICENSE that is included with this distribution. 
#*************************************************************************
menu(calcoutOOPT) {
	choice(calcoutOOPT_Every_Time,"Every Time")
	choice(calcoutOOPT_On_Change,"On Change")
	choice(calcoutOOPT_When_Zero,"When Zero")
	choice(calcoutOOPT_When_Non_zero,"When Non-zero")
	choice(calcoutOOPT_Transition_To_Zero,"Transition To Zero")
	choice(calcoutOOPT_Transition_To_Non_zero,"Transition To Non-zero")
}
menu(calcoutDOPT) {
	choice(calcoutDOPT_Use_VAL,"Use CALC")
	choice(calcoutDOPT_Use_OVAL,"Use OCAL")
}
menu(calcoutINAV) {
	choice(calcoutINAV_EXT_NC,"Ext PV NC")
	choice(calcoutINAV_EXT,"Ext PV OK")
	choice(calcoutINAV_LOC,"Local PV")
	choice(calcoutINAV_CON,"Constant")
}
recordtype(calcout) {
	include "dbCommon.dbd" 
	field(RPVT,DBF_NOACCESS) {
		prompt("Record Private")
		special(SPC_NOMOD)
		interest(4)
		extra("struct rpvtStruct *rpvt")
	}
	field(VAL,DBF_DOUBLE) {
		prompt("Result")
		promptgroup("50 - Output")
		asl(ASL0)
	}
	field(PVAL,DBF_DOUBLE) {
		prompt("Previous Value")
	}
	field(CALC,DBF_STRING) {
		prompt("Calculation")
		promptgroup("30 - Action")
		special(SPC_CALC)
		pp(TRUE)
		size(80)
		initial("0")
	}
	field(CLCV,DBF_LONG) {
		prompt("CALC Valid")
		interest(1)
	}
	field(INPA,DBF_INLINK) {
		prompt("Input A")
		special(SPC_MOD)
		promptgroup("41 - Input A-F")
		interest(1)
	}
	field(INPB,DBF_INLINK) {
		prompt("Input B")
		special(SPC_MOD)
		promptgroup("41 - Input A-F")
		interest(1)
	}
	field(INPC,DBF_INLINK) {
		prompt("Input C")
		special(SPC_MOD)
		promptgroup("41 - Input A-F")
		interest(1)
	}
	field(INPD,DBF_INLINK) {
		prompt("Input D")
		special(SPC_MOD)
		promptgroup("41 - Input A-F")
		interest(1)
	}
	field(INPE,DBF_INLINK) {
		prompt("Input E")
		special(SPC_MOD)
		promptgroup("41 - Input A-F")
		interest(1)
	}
	field(INPF,DBF_INLINK) {
		prompt("Input F")
		special(SPC_MOD)
		promptgroup("41 - Input A-F")
		interest(1)
	}
	field(INPG,DBF_INLINK) {
		prompt("Input G")
		special(SPC_MOD)
		promptgroup("42 - Input G-L")
		interest(1)
	}
	field(INPH,DBF_INLINK) {
		prompt("Input H")
		special(SPC_MOD)
		promptgroup("42 - Input G-L")
		interest(1)
	}
	field(INPI,DBF_INLINK) {
		prompt("Input I")
		special(SPC_MOD)
		promptgroup("42 - Input G-L")
		interest(1)
	}
	field(INPJ,DBF_INLINK) {
		prompt("Input J")
		special(SPC_MOD)
		promptgroup("42 - Input G-L")
		interest(1)
	}
	field(INPK,DBF_INLINK) {
		prompt("Input K")
		special(SPC_MOD)
		promptgroup("42 - Input G-L")
		interest(1)
	}
	field(INPL,DBF_INLINK) {
		prompt("Input L")
		special(SPC_MOD)
		promptgroup("42 - Input G-L")
		interest(1)
	}
	field(OUT,DBF_OUTLINK) {
		prompt("Output Specification")
		special(SPC_MOD)
		promptgroup("50 - Output")
		interest(1)
	}
	field(INAV,DBF_MENU) {
		prompt("INPA PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INBV,DBF_MENU) {
		prompt("INPB PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INCV,DBF_MENU) {
		prompt("INPC PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INDV,DBF_MENU) {
		prompt("INPD PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INEV,DBF_MENU) {
		prompt("INPE PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INFV,DBF_MENU) {
		prompt("INPF PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INGV,DBF_MENU) {
		prompt("INPG PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INHV,DBF_MENU) {
		prompt("INPH PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INIV,DBF_MENU) {
		prompt("INPI PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INJV,DBF_MENU) {
		prompt("INPJ PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INKV,DBF_MENU) {
		prompt("INPK PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(INLV,DBF_MENU) {
		prompt("INPL PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
		initial("1")
	}
	field(OUTV,DBF_MENU) {
		prompt("OUT PV Status")
		special(SPC_NOMOD)
		interest(1)
		menu(calcoutINAV)
	}
	field(OOPT,DBF_MENU) {
		prompt("Output Execute Opt")
		promptgroup("50 - Output")
		interest(1)
		menu(calcoutOOPT)
	}
	field(ODLY,DBF_DOUBLE) {
		prompt("Output Execute Delay")
		promptgroup("50 - Output")
		asl(ASL0)
		interest(1)
	}
	field(DLYA,DBF_USHORT) {
		prompt("Output Delay Active")
		special(SPC_NOMOD)
		asl(ASL0)
	}
	field(DOPT,DBF_MENU) {
		prompt("Output Data Opt")
		promptgroup("30 - Action")
		interest(1)
		menu(calcoutDOPT)
	}
	field(OCAL,DBF_STRING) {
		prompt("Output Calculation")
		promptgroup("30 - Action")
		special(SPC_CALC)
		pp(TRUE)
		size(80)
		initial("0")
	}
	field(OCLV,DBF_LONG) {
		prompt("OCAL Valid")
		interest(1)
	}
	field(OEVT,DBF_STRING) {
		prompt("Event To Issue")
		promptgroup("30 - Action")
		special(SPC_MOD)
		asl(ASL0)
		size(40)
	}
	%#include "dbScan.h"
	field(EPVT, DBF_NOACCESS) {
		prompt("Event private")
		special(SPC_NOMOD)
		interest(4)
		extra("EVENTPVT epvt")
	}
	field(IVOA,DBF_MENU) {
		prompt("INVALID output action")
		promptgroup("50 - Output")
		interest(2)
		menu(menuIvoa)
	}
	field(IVOV,DBF_DOUBLE) {
		prompt("INVALID output value")
		promptgroup("50 - Output")
		interest(2)
	}
	field(EGU,DBF_STRING) {
		prompt("Engineering Units")
		promptgroup("80 - Display")
		interest(1)
		size(16)
		prop(YES)
	}
	field(PREC,DBF_SHORT) {
		prompt("Display Precision")
		promptgroup("80 - Display")
		interest(1)
		prop(YES)
	}
	field(HOPR,DBF_DOUBLE) {
		prompt("High Operating Rng")
		promptgroup("80 - Display")
		interest(1)
		prop(YES)
	}
	field(LOPR,DBF_DOUBLE) {
		prompt("Low Operating Range")
		promptgroup("80 - Display")
		interest(1)
		prop(YES)
	}
	field(HIHI,DBF_DOUBLE) {
		prompt("Hihi Alarm Limit")
		promptgroup("70 - Alarm")
		pp(TRUE)
		interest(1)
		prop(YES)
	}
	field(LOLO,DBF_DOUBLE) {
		prompt("Lolo Alarm Limit")
		promptgroup("70 - Alarm")
		pp(TRUE)
		interest(1)
		prop(YES)
	}
	field(HIGH,DBF_DOUBLE) {
		prompt("High Alarm Limit")
		promptgroup("70 - Alarm")
		pp(TRUE)
		interest(1)
		prop(YES)
	}
	field(LOW,DBF_DOUBLE) {
		prompt("Low Alarm Limit")
		promptgroup("70 - Alarm")
		pp(TRUE)
		interest(1)
		prop(YES)
	}
	field(HHSV,DBF_MENU) {
		prompt("Hihi Severity")
		promptgroup("70 - Alarm")
		pp(TRUE)
		interest(1)
		prop(YES)
		menu(menuAlarmSevr)
	}
	field(LLSV,DBF_MENU) {
		prompt("Lolo Severity")
		promptgroup("70 - Alarm")
		pp(TRUE)
		interest(1)
		prop(YES)
		menu(menuAlarmSevr)
	}
	field(HSV,DBF_MENU) {
		prompt("High Severity")
		promptgroup("70 - Alarm")
		pp(TRUE)
		interest(1)
		prop(YES)
		menu(menuAlarmSevr)
	}
	field(LSV,DBF_MENU) {
		prompt("Low Severity")
		promptgroup("70 - Alarm")
		pp(TRUE)
		interest(1)
		prop(YES)
		menu(menuAlarmSevr)
	}
	field(HYST,DBF_DOUBLE) {
		prompt("Alarm Deadband")
		promptgroup("70 - Alarm")
		interest(1)
	}
	field(ADEL,DBF_DOUBLE) {
		prompt("Archive Deadband")
		promptgroup("80 - Display")
		interest(1)
	}
	field(MDEL,DBF_DOUBLE) {
		prompt("Monitor Deadband")
		promptgroup("80 - Display")
		interest(1)
	}
	field(A,DBF_DOUBLE) {
		prompt("Value of Input A")
		pp(TRUE)
	}
	field(B,DBF_DOUBLE) {
		prompt("Value of Input B")
		pp(TRUE)
	}
	field(C,DBF_DOUBLE) {
		prompt("Value of Input C")
		pp(TRUE)
	}
	field(D,DBF_DOUBLE) {
		prompt("Value of Input D")
		pp(TRUE)
	}
	field(E,DBF_DOUBLE) {
		prompt("Value of Input E")
		pp(TRUE)
	}
	field(F,DBF_DOUBLE) {
		prompt("Value of Input F")
		pp(TRUE)
	}
	field(G,DBF_DOUBLE) {
		prompt("Value of Input G")
		pp(TRUE)
	}
	field(H,DBF_DOUBLE) {
		prompt("Value of Input H")
		pp(TRUE)
	}
	field(I,DBF_DOUBLE) {
		prompt("Value of Input I")
		pp(TRUE)
	}
	field(J,DBF_DOUBLE) {
		prompt("Value of Input J")
		pp(TRUE)
	}
	field(K,DBF_DOUBLE) {
		prompt("Value of Input K")
		pp(TRUE)
	}
	field(L,DBF_DOUBLE) {
		prompt("Value of Input L")
		pp(TRUE)
	}
	field(OVAL,DBF_DOUBLE) {
		prompt("Output Value")
		asl(ASL0)
	}
	field(LA,DBF_DOUBLE) {
		prompt("Prev Value of A")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LB,DBF_DOUBLE) {
		prompt("Prev Value of B")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LC,DBF_DOUBLE) {
		prompt("Prev Value of C")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LD,DBF_DOUBLE) {
		prompt("Prev Value of D")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LE,DBF_DOUBLE) {
		prompt("Prev Value of E")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LF,DBF_DOUBLE) {
		prompt("Prev Value of F")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LG,DBF_DOUBLE) {
		prompt("Prev Value of G")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LH,DBF_DOUBLE) {
		prompt("Prev Value of H")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LI,DBF_DOUBLE) {
		prompt("Prev Value of I")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LJ,DBF_DOUBLE) {
		prompt("Prev Value of J")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LK,DBF_DOUBLE) {
		prompt("Prev Value of K")
		special(SPC_NOMOD)
		interest(3)
	}
	field(LL,DBF_DOUBLE) {
		prompt("Prev Value of L")
		special(SPC_NOMOD)
		interest(3)
	}
	field(POVL,DBF_DOUBLE) {
		prompt("Prev Value of OVAL")
		asl(ASL0)
	}
	field(LALM,DBF_DOUBLE) {
		prompt("Last Value Alarmed")
		special(SPC_NOMOD)
		interest(3)
	}
	field(ALST,DBF_DOUBLE) {
		prompt("Last Value Archived")
		special(SPC_NOMOD)
		interest(3)
	}
	field(MLST,DBF_DOUBLE) {
		prompt("Last Val Monitored")
		special(SPC_NOMOD)
		interest(3)
	}
	%#include "postfix.h"
	field(RPCL,DBF_NOACCESS) {
		prompt("Reverse Polish Calc")
		special(SPC_NOMOD)
		interest(4)
		extra("char	rpcl[INFIX_TO_POSTFIX_SIZE(80)]")
	}
	field(ORPC,DBF_NOACCESS) {
		prompt("Reverse Polish OCalc")
		special(SPC_NOMOD)
		interest(4)
		extra("char	orpc[INFIX_TO_POSTFIX_SIZE(80)]")
	}
}

variable(calcoutODLYprecision, int)
variable(calcoutODLYlimit, double)
