\section{EPICS Scaler}
%
\textit{Module: \bf{epics.mxo}}
\newline

MX defines the concept of a scaler record differently than EPICS.  In MX,
each scaler channel has its own separate scaler record and the timer that
gates the scaler channel has it own separate timer record too.  In EPICS,
all of the above would be combined into one EPICS scaler record.  In most
of what we say below, we use the MX definition of the terms.

The MX EPICS scaler support optionally can make use of globally visible dark
current values.  This is done by loading an additional EPICS database file
in ``st.cmd'' that can be found in the MX base distribution in the file
\textit{mx/driver\_info/epics\_scaler/Jscaler\_dark.db}.
This EPICS database implements two additional records per EPICS scaler channel.
For example, for scaler channel 2 the records are
\begin{itemize}
  \item \$(P)\$(S)\_Dark2.VAL   - Dark current per second for scaler channel 2.
  \item \$(P)\$(S)\_SD2.VAL     - The dark current subtracted value for scaler 2.
\end{itemize}
where \$(P) and \$(S) are defined to have the same values as in the standard
Jscaler.db database.  The database is loaded into the EPICS VME crate by
adding a line to the 'st.cmd' startup script that looks like
\begin{verbatim}

dbLoadRecords("iocBoot/ioc1/Jscaler_dark.db","P=s10id:,S=scaler1,C=0", top)

\end{verbatim}

Please note that this database contains a definition for the scaler record
\$(P) and \$(S) itself and thus is not immediately compatible with the standard
\textit{Jscaler.db} database.  This is due to the fact that EPICS does not
supply any way for an add-on database to add forward links to existing records.
If you wish to combine \textit{Jscaler.db} and \textit{Jscaler\_dark.db},
the simplest way
is to merely move the FLNK field whose value is ``\$(P)\$(S)\_cts1.PROC'' in 
Jscaler.db to the LNK4 field of Fanout record ``\$(P)\$(S)\_fan0'' defined
in \textit{Jscaler\_dark.db}.

Hopefully, something equivalent to the dark current fields in 
\textit{Jscaler\_dark.db} will be added to some future version
of \textit{Jscaler.db}.

\newcommand{\MxFieldEpicsZscalerEpicsZrecordZname}
{The part of the EPICS scaler PV name before the final period `.' character.}
\newcommand{\MxFieldEpicsZscalerScalerZnumber}
{The number of the EPICS scaler channel.}
\ \newline
\MxEpicsZscalerDriverFields
\newline

For example, if the EPICS PV for a given scaler channel 
is {wml:scaler1.S5}, then the \textit{epics\_record\_name} above is 
``wml:scaler1'', while the \textit{scaler\_number} is ``5''.
An example MX database entry for such a scaler channel would look like this
\begin{verbatim}
scaler5 device scaler epics_scaler "" "" 0 0 1 timer1 wml:scaler1 5
\end{verbatim}
