Table of Contents Previous Chapter Chapter 20: mbbi - MultiBit Binary Input

Chapter 20: mbbi - MultiBit Binary Input

1. Introduction

The normal use for the mbbi record type is to obtain a binary value that represents one of up to 16 states. Most device support modules obtain values from hardware and place the value in RVAL. For these devices record processing uses RVAL to determine the current state (VAL is given a value between 0 and 15). Devices may optionally read a value directly into VAL. Soft device modules are provided to obtain input via database or channel access links or via dbPutField or dbPutLink requests. Two soft device support modules are provided. One allows VAL to be an arbitrary unsigned short integer. The other reads the value into RVAL just like normal hardware modules.

2. Field Summary

--------------------------------------------------------------
Field  Type       DCT  Initial  Access  Modify  Rec Proc   PP   
                                                Monitor         
--------------------------------------------------------------
VAL    ENUM       No   0        Yes     Yes     Yes        Yes  
NOBT   SHORT      Yes  0        Yes     No                 No   
INP    INLINK     Yes  0        No      No      N/A        No   
ZRVL   ULONG      Yes  0        Yes     Yes     No         Yes  
ONVL   ULONG      Yes  0        Yes     Yes     No         Yes  
TWVL   ULONG      Yes  0        Yes     Yes     No         Yes  
THVL   ULONG      Yes  0        Yes     Yes     No         Yes  
FRVL   ULONG      Yes  0        Yes     Yes     No         Yes  
FVVL   ULONG      Yes  0        Yes     Yes     No         Yes  
SXVL   ULONG      Yes  0        Yes     Yes     No         Yes  
SVVL   ULONG      Yes  0        Yes     Yes     No         Yes  
EIVL   ULONG      Yes  0        Yes     Yes     No         Yes  
NIVL   ULONG      Yes  0        Yes     Yes     No         Yes  
TEVL   ULONG      Yes  0        Yes     Yes     No         Yes  
ELVL   ULONG      Yes  0        Yes     Yes     No         Yes  
TVVL   ULONG      Yes  0        Yes     Yes     No         Yes  
TTVL   ULONG      Yes  0        Yes     Yes     No         Yes  
FTVL   ULONG      Yes  0        Yes     Yes     No         Yes  
FFVL   ULONG      Yes  0        Yes     Yes     No         Yes  
ZRST   STRING     Yes  Null     Yes     Yes     No         Yes  
ONST   STRING     Yes  Null     Yes     Yes     No         Yes  
TWST   STRING     Yes  Null     Yes     Yes     No         Yes  
THST   STRING     Yes  Null     Yes     Yes     No         Yes  
FRST   STRING     Yes  Null     Yes     Yes     No         Yes  
FVST   STRING     Yes  Null     Yes     Yes     No         Yes  
SXST   STRING     Yes  Null     Yes     Yes     No         Yes  
SVST   STRING     Yes  Null     Yes     Yes     No         Yes  
EIST   STRING     Yes  Null     Yes     Yes     No         Yes  
NIST   STRING     Yes  Null     Yes     Yes     No         Yes  
TEST   STRING     Yes  Null     Yes     Yes     No         Yes  
ELST   STRING     Yes  Null     Yes     Yes     No         Yes  
TVST   STRING     Yes  Null     Yes     Yes     No         Yes  
TTST   STRING     Yes  Null     Yes     Yes     No         Yes  
FTST   STRING     Yes  Null     Yes     Yes     No         Yes  
FFST   STRING     Yes  Null     Yes     Yes     No         Yes  
ZRSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
ONSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
TWSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
THSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
FRSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
FVSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
SXSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
SVSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
EISV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
NISV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
TESV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
ELSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
TVSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
TTSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
FTSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
FFSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
UNSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
COSV   GBLCHOICE  Yes  0        Yes     Yes     No         Yes  
RVAL   ULONG      No   0        Yes     Yes     Yes        Yes  
ORAW   ULONG      No   0        Yes     No      No         No   
MASK   ULONG      No   0        Yes     No      No         No   
MLST   USHORT     No   0        Yes     No      No         No   
LALM   USHORT     No   0        Yes     No      No         No   
SDEF   SHORT      No   0        Yes     No      No         No   
SHFT   USHORT     No   0        Yes     No      No         No   
SIOL   INLINK     Yes  0        No      No      N/A        No   
SVAL   USHORT     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          Unless INP is a constant link, this is the value resulting     
                                     from the record being processed. If INP is a constant, then    
                                     VAL is initialized to the INP value but can be changed         
                                     dynamically via dbPutField or dbPutLink. It                    
                                     normally is the index (0 to 15) of the current state.          
NOBT            Number of Bits       Number of bits set in hardware mask.                           
INP             Input Link           This field is used by the device support routines to obtain    
                                     input. For soft records, it can be a constant, a database      
                                     link, or a channel access link.                                
ZRVL,...,FFVL   Zero Value, One      Masks for hardware value associated with each state.           
                Value ...                                                                           
ZRST,...,FFST   Zero String, One     Strings associated with each state.                            
                String ...                                                                          
ZRSV,...,FFSV   Zero Severity, One   Alarm severity associated with each state.                     
                Severity,...                                                                        
UNSV            Unknown State                                                                       
                Severity                                                                            
COSV            Change of State                                                                     
                Severity                                                                            
RVAL            Raw Data Value       RVAL is the value obtained by the device support routine.      
                                     Unless the device support routine specifies no conversion,     
                                     VAL is determined as follows: A temporary variable rval        
                                     is set equal to RVAL. It is then shifted right SHFT bits.      
                                     After shifting, the result should match one of the values      
                                     ZRVL,...,FFVL.                                                 
ORAW            Old Raw Data         ORAW is used to decide if monitors should be triggered for     
                Value                RVAL at the same time monitors are triggered for changes       
                                     in VAL.                                                        
MASK            Mask                 Mask used by device support routine to read hardware           
                                     register. Record support sets low order NOBT bits. Device      
                                     support can shift this value.                                  
SHFT            Shift                Number of bits to shift values obtained from RVAL.             
LALM            Last Alarmed         Value when last change of state alarm was issued.              
MLST            Monitor Last         Value when last monitor for value changes was triggered        
SDEF            States Defined?      Record support uses this field to save time if no states are   
                                     defined                                                        
SIMM            Simulation Mode      Simulation mode process variables.  Refer to Chapter 3,        
                                     Section "Simulation Mode" on page 11 for more                  
                                     information.                                                   
SIML            Simulation Mode                                                                     
                Location                                                                            
SVAL            Simulation Value                                                                    
SIOL            Simulation Value                                                                    
                Location                                                                            
SIMS            Simulation Mode                                                                     
                Alarm Severity                                                                      
--------------------------------------------------------------------------------------------------

4. Record Support Routines

init_record

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 support is available and a device support read routine is defined. If either does not exist, an error message is issued and processing is terminated.

Clears MASK and then sets the NOBT low order bits.

If device support includes init_record, it is called.

init_common is then called to determine if any states are defined. If states are defined, SDEF is set to TRUE.

process

See next section.

special

Calls init_common to compute SDEF when any of the fields ZRVL, ... FFVL change value.

get_value

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

get_enum_str

Retrieves ASCII string corresponding to VAL.

get_enum_strs

Retrieves ASCII strings for ZRST,...FFST.

put_enum_str

Checks if string matches ZRST,...FFST and if it does, sets 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 still 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 reading a new input value. In this case, the processing routine merely returns, leaving PACT TRUE.
  4. Convert.
  5. Check alarms. This routine checks to see if the new VAL causes the alarm status and severity to change. If so, NSEV, NSTA and LALM are set.
  6. Check to see if monitors should be invoked.
  7. Scan forward link if necessary, set PACT FALSE, and return.

6. Device Support

Fields Of Interest To Device Support

Each input record must have an associated set of device support routines. The primary responsibility of the device support routines is to obtain a new raw input value whenever read_mbbi is called. The device support routines are primarily interested in the following fields:

-----------------------------------------------------------------------------------------
Name  Summary             Description                                                      
-----------------------------------------------------------------------------------------
PACT  Processing Active   See Chapter 2, Section "Database Common: Field                   
                          Descriptions" on page 4 for descriptions.                        
DPVT  Device Private                                                                       
UDF   VAL Undefined                                                                        
NSEV  New Alarm Severity                                                                   
NSTA  New Alarm Status                                                                     
NOBT  Number of Bits      Number of hardware bits accessed. They must be                   
                          consecutive.                                                     
VAL   Value Field         This field is set by the device support routines if they         
                          don't want record support to set it.                             
INP   Input Link          This field is used by the device support routines to locate      
                          its input.                                                       
RVAL  Raw Data Value      It is the responsibility of the device support routine to give   
                          this field a value.                                              
MASK  Mask                This is a mask used to read the hardware. Record support         
                          sets the low order NOBT bits. The device support routine         
                          can shift the bits. The device support routine should            
                          perform the shift in in init_record.                             
SHFT  Shift               This can be set by the device support module at                  
                          init_record time.                                                
-----------------------------------------------------------------------------------------

Device Support Routines

Device support consists of the following routines:

report

  report(FILE fp, paddr)
Not currently used.

init

  init()
This routine is called once during IOC initialization.

init_record

  init_record(precord)
This routine is optional. If provided, it is called by the record support init_record routine. If it uses MASK, it should shift it as necessary and also give SHFT a value.

get_ioint_info

  get_ioint_info(int cmd,struct dbCommon *precord,IOSCANPVT *ppvt)
This routine is called by the ioEventScan system each time the record is added or deleted from an I/O event scan list. cmd has the value (0,1) if the record is being (added to, deleted from) an I/O event list. It must be provided for any device type that can use the ioEvent scanner.

read_mbbi

  read_mbbi(precord)
This routine must provide a new input value. It returns the following values:

7. Device Support For Soft Records

Two soft device support modules Soft Channel and Raw Soft Channel are provided for multibit binary input records not related to actual hardware devices. The INP link type must be either CONSTANT, DB_LINK, or CA_LINK.

Soft Channel

read_mbbi always returns a value of 2, which means that no conversion is performed.

If the INP link type is constant, then the constant value is stored into VAL by init_record, and UDF is set to FALSE. VAL can be changed via dbPut requests. If the INP link type is PV_LINK, then dbCaAddInlink is called by init_record.

read_mbbi calls recGblGetLinkValue to read the current value of VAL. See Chapter 3, Section "Soft Input" on page 10 for details.

If the return status of recGblGetLinkValue is zero, then read_mbbi sets UDF to FALSE. The status of recGblGetLinkValue is returned.

Raw Soft Channel

This module is like the previous except that values are read into RVAL, VAL is computed from RVAL, and read_mbbi returns a value of 0. Thus the record processing routine will determine VAL in the normal way.

 
Table of Contents Next Chapter