Table of Contents Previous Chapter Chapter 17: Histogram

Chapter 17: Histogram

1. Introduction

The histogram record type is used to store frequency counts of a signal into an array of arbitrary length.

2. Field Summary

Field  Type       DCT  Initial  Access  Modify  Rec Proc   PP  
VAL    See BPTR   No   0        Yes     No      No         No  
NELM   USHORT     Yes  1        Yes     No      No         No  
CSTA   SHORT      No   1        Yes     No                 No  
CMD    RECCHOICE  No   0        Yes     Yes                No  
ULIM   DOUBLE     Yes  0        Yes     Yes     No         No  
LLIM   DOUBLE     Yes  0        Yes     Yes     No         No  
WDTH   DOUBLE     No   0        Yes     No                 No  
SGNL   DOUBLE     No   0        Yes     Yes     Yes        No  
SVL    INLINK     Yes  0        No      No      N/A        No  
BPTR   NOACCESS   No   0        No      No                 No  
WDOG   NOACCESS   No   0        No      No                 No  
MCNT   SHORT      No   0        Yes     No                 No  
MDEL   SHORT      Yes  0        Yes     Yes     No         No  
SDEL   FLOAT      Yes  0        Yes     No                 No  
SIOL   INLINK     Yes  0        No      No      N/A        No  
SVAL   DOUBLE     No   0        Yes     Yes     No         No  
SIML   INLINK     Yes  0        No      No      N/A        No  
SIMM   GBLCHOICE  No   0        Yes     Yes     No         No  
SIMS   GBLCHOICE  Yes  0        Yes     Yes     No         No  

3. Field Descriptions

Name  Summary              Description                                                    
VAL   Value Field          This field is used to reference the array.                     
NELM  Number of                                                                           
      elements in array                                                                   
CSTA  Collections Status                                                                  
CMD   Collections Control                                                                 
ULIM  Upper Signal Limit   These fields determine the range of signal values to be        
                           used.   This range is subdivided into NELM equal intervals.    
                           The histogram array elements contain frequency counts of       
                           SGNL values for these intervals.  Values of the signal         
                           outside these limits are not used by the record support        
                           routines. Whenever ULIM or LLIM are changed, the array         
                           elements counts will be reset to zero.                         
LLIM  Lower Signal Limit                                                                  
WDTH  Element Width                                                                       
SGNL  Signal Value                                                                        
SVL   Signal Value         This field can be a constant, a database link, or a channel    
      Location (input      access link. If SVL is a database or channel access link,      
      link)                then SGNL is read from SVL.  If SVL is a constant link         
                           then SGNL is initialized with the constant value but can be    
                           changed via dbPuts.                                            
BPTR  Buffer Pointer       Address of unsigned long array of frequency values.            
WDOG  Watchdog Callback                                                                   
MCNT  Monitor Counts       Number of counts since last monitor.                           
MDEL  Monitor Delta        Monitor count deadband.                                        
SDEL  Monitor Seconds                                                                     
SIMM  Simulation Mode      Simulation mode process variables.  Refer to Chapter 3,        
                           Section "Simulation Mode" on page 11 for more                  
SIML  Simulation Mode                                                                     
SVAL  Simulation Value                                                                    
SIOL  Simulation Value                                                                    
SIMS  Simulation Mode                                                                     
      Alarm Severity                                                                      

4. Record Support Routines


Using NELM, space for the unsigned long array is allocated and the width WDTH of the array is calculated

This routine initializes SIMM with the value of SIML if SIML type is CONSTANT link or creates a channel access link if SIML type is PV_LINK. SVAL is likewise initialized if SIOL is CONSTANT or PV_LINK.

This routine next checks to see that device supportand a device support read routine are available. If device support includes init_record, it is called.


See next section.


Special is invoked whenever the fields CMD, SGNL, ULIM, or LLIM are changed. If SGNL is changed, add_count is called.

If ULIM or LLIM are changed, WDTH is recalculated and clear_histogram is called.

If CMD is less or equal to 1, clear_histogram is called and CMD is reset to 0. If CMD is 2, CSTA is set to TRUE and CMD is reset to 0. If CMD is 3, CSTA is set to FALSE and CMD is reset to 0.

clear_histogram zeros out the histogram array. add_count increments the frequency in the histogram array.


Fills in the values of struct valueDes so that they refer to the array.


This is called by dbNameToAddr. It makes the dbAddr structure refer to the actual buffer holding the array.


Obtains values from the array referenced by VAL.


Writes values into the array referenced by VAL.

5. Record Processing

Routine process implements the following algorithm:

  1. Check to see that the appropriate device support module exists. If it doesn't, an error message is issued and processing is terminated with the PACT field set to TRUE. This ensures that processes will no longer be called for this record. Thus error storms will not occur.
  2. readValue is called. See Chapter 3, Section "Simulation Mode" on page 11 for details.
  3. If PACT has been changed to TRUE, the device support read routine has started but has not completed writing the new value. In this case, the processing routine merely returns, leaving PACT TRUE.
  4. Add count to histogram array.
  5. Check to see if monitors should be invoked. Alarm monitors are invoked if the alarm status or severity has changed. Archive and value change monitors are invoked if MDEL conditions are met. NSEV and NSTA are reset to 0.
  6. Scan forward link if necessary, set PACT and INIT to FALSE, and return.
Table of Contents Next Chapter