man8/TIMEmngr

Table of Contents

Name

TIMEmngr - timer manager

Synopsis

TIMEmngr <argument list>

Description

TIMEmngr manages timers in an AccelNET database.

Timers are created in the AccelNET database with a Lin datatype. The variable is usually displayed with a Thms or Tdhms display key.

TIMEmngr can increment or decrement the datapoint according to instructions in the configuration table. Increment or decrement can be gated on/off and the datapoint may be reset by either writing a new value into the datapoint or by using a reset input.

If the counter is in down count mode terminal count is taken from the resp1 variable’s DESC.PhyMin value. If the counter is in up count mode terminal count is taken from the resp1 variable’s DESC.PhyMax value. The comm4 parameter may be used instead as the terminal count value.

When TIMEmngr is started it looks for the logging file using log_path if present otherwise the current working directory is used with the name TIMEmngr_data. If the file is found the values from it are loaded into the database.

If the file is not found a defaults file is looked for and if found the values are loaded into the database. The file name for the defaults file is formed by adding .def to the filename.

After startup TIMEmngr logs the timer values to disk once per minute using the pathname given by log_path.

When the file is updated the old copy is renamed <filename>.old and a new copy is created.

The program is also capable of performing averaging, integration and finding the peak min and max values.

Average calculation

TIMEmngr can calculate an average at the same time a counter is running.

If this feature is in use then each time TIMEmngr "ticks" the value of read1 is added to a running total then divided by the number of "ticks" to produce the average value. The final result is placed in the database variable named by resp4.

That is: resp4 = Vintegral/elapsed_time

If the counter is reset by using the comm2 parameter the average value is set to zero.

Integration calculation

TIMEmngr can calculate an integral at the same time a counter is running.

If this feature is in use then each time TIMEmngr "ticks" the value of read1 is first multiplied by read1.preset to scale the value then the result is multiplied by deltaT (the tick interval, approximently one second) and the final result is added to the value of resp1.

That is: resp3 += (dT * (read1.current * read1.preset))

If the counter is reset by using the comm2 parameter the integration value is set to zero.

Peak minimum and maximum calculations

A peak minimum and peak maximum may be calculated. Each time a "tick" occurs read1 is examined to see if its value is greater than peak maximum or less than peak minimum. If so, then the appropriate item is updated to reflect the new maxiumum or minimum excursion.

resp5 index 0 is used for peak minimum and resp5 index 1 is used for peak maximum.

The AccelNET datatyping rules are followed when performing the calculation. If the datatype is Lin or Alog the maximum is the most positive value and the minimum is the least positive value.

If the datatype is NLin or NAlog the rules are reversed.

These tests follow the same logic as the normal AccelNET rules for DESC record processing.

If the counter is reset by using the comm2 parameter the peak minimum and maximum values are set to zero.

Gating input

TIMEmngr provides a "gating" input which is used to determine when the timer runs.

The behavior of this input depends on the datatype of the parameter associated with it. Presently the supported datatypes are: Lin, NLin, Alog, NAlog, and Ldisp. Other datatypes could be supported, they just aren’t at the moment.

Lin, Alog

if (V >= preset) then run timer.
NLin, NAlog

if (V <= preset) then run timer.
Ldisp

if (V == preset) then run timer

Note that TIMEmngr will silently not run, i.e. there are no error messages, if this parameter is provided and the datatype is unimplemented.

Arguments

Arguments are processed using Unix long argument syntax.
--mngr <fn>

The CONFLIST file from which to obtain the configuration information.

If this is not specified it defaults to "MNGRconf" in the current working directory (i.e. the directory where the program was started).

--mngr_pn <fn>

The program name to use when parsing the CONFLIST file.

If this argument is not specified it generally defaults to the program name.

--data_path <pn>

The pathname to the directory where logging files are read and written.

The log files in this directory are given the name "<log_path>".

The old log files are given the name "<log_path>.old".

The default files are given the name "<log_path>.def".

--show_tbl

If this argument is present the contents of the CONFLIST table is printed to stderr
--diag

If this argument is present stdout and stdin are left open and the program may be killed by SIGINT.

This argument is useful when setting up the parameters for the PID loop(s) because it makes it very easy to kill and restart the program after changing the config file.

--verbose=<n>

Normally the program does it’s work silently. This sets the level of logging information. The number is optional but if provided it must include the "=". If no argument is provided the default level is 1.
0 - work silently
1 - print signon msg, option settings

Configuration name usage

The configuration file uses the libmngr(3mngr) facility to connect internal parameters to the AccelNET database. The mappings for this program are given below.

Parameters needed by this program can be combined with parameters belonging to other programs. The "program name" field in the configuration file differentiates the entries.

TIMEmngr uses "TIMEmngr" as the program name when searching the file.

Any number of groups up to the maximum may be used.

comm1 - optional

The gating input.

The write permissions should be set for direct update and the owner may be any task.

See the Gating Input section for more information.

comm2 - optional

Reset input.

if (V == preset) then resp1.current = resp1.preset

The write permissions should be set for direct update and the owner may be any task.

If comm3 is present it will be used to reload the counter instead of resp1.preset. See comm3 below for more information.

comm3 - optional

Preset value input.

If this parameter is present then it will be used instead of resp1.preset for reloading the timer.

The value will be taken from comm3.preset if the Label and RefName are NULL else it will be taken from the database.

The write permissions should be set for direct update and the owner may be any task.

Note that the normal database PhyMin and PhyMax rules still apply to resp1 when using the parameter.

This means (using the Lin datatype as an example) that the value entered into this datapoint must fall between the PhyMin and PhyMax values for the resp1 data point.

TIMEmngr enforces these rules internally.

comm4 - optional

Terminal count value input.

If this parameter is present then it will be used as the terminal count value.

The write permissions should be set for direct update and the owner may be any task.

The value will be taken from comm4.preset if the Label and RefName are NULL else it will be taken from the database.

Note that the normal database PhyMin and PhyMax rules still apply to resp1 when using the parameter.

This means (using the Lin datatype as an example) that the value entered into this datapoint must fall between the PhyMin and PhyMax values for the resp1 data point.

TIMEmngr enforces these rules internally.

resp1 - required

The database variable to use as a timer.

The user may enter a new value into this variable and the counter will count up or down (depending on the count direction, see const0) starting from this value.

The write permissions should be set to ______IU (indirect update by users, unconditional update by owner) and the owner should be the same as what TIMEmngr registers as.

Note that the normal database PhyMin and PhyMax rules still apply when using the parameter. In other words PhyMax must be set to value greater than or equal to the largest expected time value or the counter will stop when the value exceeds PhyMax.

TIMEmngr enforces this rule internally.

resp2 - optional

The database variable to use for timer status.

The datapoint should be made large enough to hold four possible values. The four values are:

0 - stopped
1 - paused
2 - running
3 - not used

The write permissions should be set for direct update and the owner should be the same as what TIMEmngr registers as.

resp3 - optional

The database variable to use for the integral.

The user may enter a new value into this variable and integration will begin or continue from this value.

The write permissions should be set to ______IU (indirect update by users, unconditional update by owner) and the owner should be the same as what TIMEmngr registers as.

Note that the normal database PhyMin and PhyMax rules still apply when using the parameter. In other words PhyMax must be set to value greater than or equal to the largest expected value or integration will stop when the value exceeds PhyMax (but the counter will still run).

See the Integration calculation section for more information.

resp4 - optional

The database variable to use for the average.

The write permissions should be set for direct update and the owner should be the same as what TIMEmngr registers as.

Note that the normal database PhyMin and PhyMax rules still apply when using the parameter. In other words PhyMax must be set to value greater than or equal to the largest expected value or integration will stop when the value exceeds PhyMax (but the counter will still run).

See the Average calculation section for more information.

resp5 - optional

The database variable(s) to use for the peak minimum and peak maximum.

index0 is used for the minimum and index1 is used for the maximum.

The write permissions should be set for direct update and the owner should be the same as what TIMEmngr registers as.

Note that the normal database PhyMin and PhyMax rules still apply when using these parameters. In other words PhyMax must be set to value greater than or equal to the largest expected value or integration will stop when the value exceeds PhyMax (but the counter will still run).

See the Peak minimum and maximum calculation section for more information.

See also the NOTES section below.

read1 - optional

The input value for the average, integral, and peak min/max calculations.

The value is multiplied by the preset field.

This may be used to provide scaling of the integral otherwise preset should be set to 1.0.

See the Integration calculation section for more information.

const0 - optional

Direction control.

If the value is zero the timer increments, otherwise it decrements.

If the Label and RefName fields are not NULL i.e. they point to a valid parameter in the database that value will be used, else the value of CONFLIST.Preset will be used.

Examples


#
#    this example runs two timers
#
#
#    this is a chain runtime counter
#    it counts upward when the PwrSR says
#    the chain is running
#
TIMEmngr|g1|comm1 |0|CH TX-1|PwrSR |1.0
TIMEmngr|g1|resp1 |0|CH TX-1|RunTime |
#
#
#
#    this a cathode lifetime counter
#    it decrements when the cathode current
#    is above a -3mA limit (comm1.preset)
#    It is reset to the starting value when
#    the reset input (comm2) is at the value
#    given by comm2.preset. It is set to
#    resp1.current = resp1.preset
#
TIMEmngr|g2|comm1 |0|CAT S1-1|CR |-3.0
TIMEmngr|g2|comm2 |0|CAT S1-1|ResetSC |1.0
TIMEmngr|g2|resp1 |0|CAT S1-1|RunTime |60.0
TIMEmngr|g2|const0 |0|1.0 |NULL |
#

Notes

A couple of things came to light during software testing of the peak minimum and maximum function.

The code was tested using a Faraday cup current read. In this particular case the CR was being calculated by NUMmngr from a voltage read.

Usually when this is done the CR is defined a Lin datatype with PhyMin and Max set to -1.0 and 1.0.

The particular cup read used was a preacceleration cup. This produced a somewhat strange result in the peak min/max parameters because they were reversed.

For example when the CR was varied between -1.1e-5 and -9e-6 the value placed in peak_min was -1.1e-5 and peak_max contained -9e-6.

This is reasonable because indeed -1.1e-5 is less the -9e-6 however this may not make sense in terms of beam current.

There are a couple of solutions to this problem:

1) change the CR to be NLin. This won’t make any difference to the current read but will make TIMEmngr handle the peak min/max values in a more "sensible" way (sensible at least to a physicist).

2) reverse the peak min/max assignments for resp5 in the MNGRconf file. TIMEmngr will go about it’s merry way producing peak min/max according to it’s internal rules but the parameters used in the AccelNET database will be reversed so the outside world respresentation will make physicist sense.

See Also

libmngr(3mngr)

Manual page revision

$Id: TIMEmngr.8,v 1.12 2008/03/05 20:50:41 kitchen Exp $


Table of Contents