#*************************************************************************
# Copyright (c) 2002 The University of Chicago, 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(histogramCMD) {
	choice(histogramCMD_Read,"Read")
	choice(histogramCMD_Clear,"Clear")
	choice(histogramCMD_Start,"Start")
	choice(histogramCMD_Stop,"Stop")
}
recordtype(histogram) {


	include "dbCommon.dbd"
    %
    %/* Declare Device Support Entry Table */
    %struct histogramRecord;
    %typedef struct histogramdset {
    %    dset common; /*init_record returns: (-1,0)=>(failure,success)*/
    %    long (*read_histogram)(struct histogramRecord *prec); /*(0,2)=> success and add_count, don't add_count); if add_count then sgnl added to array*/
    %    long (*special_linconv)(struct histogramRecord *prec, int after);
    %} histogramdset;
    %#define HAS_histogramdset
    %
	field(VAL,DBF_NOACCESS) {
		prompt("Value")
		asl(ASL0)
		special(SPC_DBADDR)
		extra("void *	val")
		#=type ULONG[]
		#=read Yes
		#=write Yes
	}
	field(NELM,DBF_USHORT) {
		prompt("Num of Array Elements")
		promptgroup("30 - Action")
		special(SPC_NOMOD)
		interest(1)
		initial("1")
	}
	field(CSTA,DBF_SHORT) {
		prompt("Collection Status")
		special(SPC_NOMOD)
		interest(1)
		initial("1")
	}
	field(CMD,DBF_MENU) {
		prompt("Collection Control")
		asl(ASL0)
		special(SPC_CALC)
		interest(1)
		menu(histogramCMD)
	}
	field(ULIM,DBF_DOUBLE) {
		prompt("Upper Signal Limit")
		promptgroup("30 - Action")
		special(SPC_RESET)
		interest(1)
		prop(YES)
	}
	field(LLIM,DBF_DOUBLE) {
		prompt("Lower Signal Limit ")
		promptgroup("30 - Action")
		special(SPC_RESET)
		interest(1)
		prop(YES)
	}
	field(WDTH,DBF_DOUBLE) {
		prompt("Element Width")
		special(SPC_NOMOD)
		interest(3)
	}
	field(SGNL,DBF_DOUBLE) {
		prompt("Signal Value")
		special(SPC_MOD)
	}
	field(PREC,DBF_SHORT) {
		prompt("Display Precision")
		promptgroup("80 - Display")
		interest(1)
		prop(YES)
	}
	field(SVL,DBF_INLINK) {
		prompt("Signal Value Location")
		promptgroup("40 - Input")
		interest(1)
	}
	field(BPTR,DBF_NOACCESS) {
		prompt("Buffer Pointer")
		special(SPC_NOMOD)
		interest(4)
		extra("epicsUInt32 *bptr")
	}
	field(WDOG,DBF_NOACCESS) {
		prompt("Watchdog callback")
		special(SPC_NOMOD)
		interest(4)
		extra("void *  wdog")
	}
	field(MDEL,DBF_SHORT) {
		prompt("Monitor Count Deadband")
		promptgroup("80 - Display")
		interest(1)
	}
	field(MCNT,DBF_SHORT) {
		prompt("Counts Since Monitor")
		special(SPC_NOMOD)
		interest(3)
	}
	field(SDEL,DBF_DOUBLE) {
		prompt("Monitor Seconds Dband")
		promptgroup("80 - Display")
		special(SPC_RESET)
		interest(1)
	}
	field(SIOL,DBF_INLINK) {
                prompt("Simulation Input Link")
		promptgroup("90 - Simulate")
		interest(1)
	}
	field(SVAL,DBF_DOUBLE) {
		prompt("Simulation Value")
	}
	field(SIML,DBF_INLINK) {
                prompt("Simulation Mode Link")
		promptgroup("90 - Simulate")
		interest(1)
	}
	field(SIMM,DBF_MENU) {
		prompt("Simulation Mode")
                special(SPC_MOD)
                interest(1)
		menu(menuYesNo)
	}
	field(SIMS,DBF_MENU) {
                prompt("Simulation Mode Severity")
		promptgroup("90 - Simulate")
		interest(2)
		menu(menuAlarmSevr)
	}
    field(OLDSIMM,DBF_MENU) {
        prompt("Prev. Simulation Mode")
        special(SPC_NOMOD)
        interest(4)
        menu(menuSimm)
    }
    field(SSCN,DBF_MENU) {
        prompt("Sim. Mode Scan")
        promptgroup("90 - Simulate")
        interest(1)
        menu(menuScan)
        initial("65535")
    }
    field(SDLY,DBF_DOUBLE) {
        prompt("Sim. Mode Async Delay")
        promptgroup("90 - Simulate")
        interest(2)
        initial("-1.0")
    }
    %#include "callback.h"
    field(SIMPVT,DBF_NOACCESS) {
        prompt("Sim. Mode Private")
        special(SPC_NOMOD)
        interest(4)
        extra("epicsCallback            *simpvt")
    }
        field(HOPR,DBF_ULONG) {
		prompt("High Operating Range")
		promptgroup("80 - Display")
		interest(1)
		prop(YES)
	}
	field(LOPR,DBF_ULONG) {
		prompt("Low Operating Range")
		promptgroup("80 - Display")
		interest(1)
		prop(YES)
	}


}

variable(histogramSDELprecision, int)
