# Multi-Bit Binary Input Direct Record (mbbiDirect) The mbbiDirect record retrieves a 32-bit hardware value and converts it to an array of 32 unsigned characters, each representing a bit of the word. These fields (B0-B9, BA-BF, B10-B19, B1A-B1F) are set to 1 if the corresponding bit is set, and 0 if not. This record's operation is similar to that of the [multi-bit binary input record](mbbiRecord.md), and it has many fields in common with it. This record also has two available soft device support modules: `Soft Channel` and `Raw Soft Channel`. ## Parameter Fields The record-specific fields are described below, grouped by functionality. ### Scan Parameters The mbbiDirect record has the standard fields for specifying under what circumstances the record will be processed. These fields are listed in [Scan Fields](dbCommonRecord.md#scan-fields). ### Read and Convert Parameters The device support routines obtain the record's input from the device or link specified in the INP field. For records that obtain their input from devices, the INP field must contain the address of the I/O card, and the DTYP field must specify the proper device support module. Be aware that the address format differs according to the I/O bus used. Two soft device support modules can be specified in DTYP `Soft Channel` and `Raw Soft Channel`. `Raw Soft Channel` reads the value into RVAL, upon which the normal conversion process is undergone. `Soft Channel` reads any unsigned integer directly into VAL. For a soft mbbiDirect record, the INP field can be a constant, a database, or a channel access link. If INP is a constant, then the VAL is initialized to the INP value but can be changed at run-time via dbPutField or dbPutLink. For records that don't use `Soft Channel` device support, RVAL is used to determine VAL as follows: - 1. RVAL is assigned to a temporary variable _rval_ = RVAL - 2. _rval_ is shifted right SHFT number of bits. - 3. VAL is set equal to _rval_. Each of the fields, B0-BF and B10-B1F, represents one bit of the word. | Field | Summary | Type | DCT | Default | Read | Write | CA PP | | ----- | -------------------------- | ------------- | --- | ------- | ---- | ----- | ----- | | VAL | Current Value | LONG | Yes | | Yes | Yes | Yes | | INP | Input Specification | INLINK | Yes | | Yes | Yes | No | | RVAL | Raw Value | ULONG | No | | Yes | Yes | Yes | | SHFT | Shift | USHORT | Yes | | Yes | Yes | No | | B0 | Bit 0 | UCHAR | No | | Yes | Yes | Yes | | ⋮ |||||||| | B9 | Bit 9 | UCHAR | No | | Yes | Yes | Yes | | BA | Bit 10 | UCHAR | No | | Yes | Yes | Yes | | ⋮ |||||||| | BF | Bit 15 | UCHAR | No | | Yes | Yes | Yes | | B10 | Bit 16 | UCHAR | No | | Yes | Yes | Yes | | ⋮ |||||||| | B1F | Bit 31 | UCHAR | No | | Yes | Yes | Yes | ### Operator Display Parameters These parameters are used to present meaningful data to the operator. See [Fields Common to All Record Types](dbCommonRecord.md#operator-display-parameters) for more on the record name (NAME) and description (DESC) fields. | Field | Summary | Type | DCT | Default | Read | Write | CA PP | | ----- | -------------------------- | ------------- | --- | ------- | ---- | ----- | ----- | | NAME | Record Name | STRING \[61\] | No | | Yes | No | No | | DESC | Descriptor | STRING \[41\] | Yes | | Yes | Yes | No | ### Run-time Parameters These parameters are used by the run-time code for processing the mbbi direct record. They are not configurable prior to run-time. MASK is used by device support routine to read hardware register. Record support sets low order NOBT bits in MASK. Device support can shift this value. MLST holds the value when the last monitor for value change was triggered. | Field | Summary | Type | DCT | Default | Read | Write | CA PP | | ----- | -------------------------- | ------------- | --- | ------- | ---- | ----- | ----- | | NOBT | Number of Bits | SHORT | Yes | | Yes | No | No | | ORAW | Prev Raw Value | ULONG | No | | Yes | No | No | | MASK | Hardware Mask | ULONG | No | | Yes | No | No | | MLST | Last Value Monitored | LONG | No | | Yes | No | No | ### Simulation Mode Parameters The following fields are used to operate the record in simulation mode. If SIMM (fetched through SIML) is YES or RAW, the record is put in SIMS severity and the value is fetched through SIOL (buffered in SVAL). If SIMM is YES, SVAL is written to VAL without conversion, if SIMM is RAW, SVAL is trancated to RVAL and converted. SSCN sets a different SCAN mechanism to use in simulation mode. SDLY sets a delay (in sec) that is used for asynchronous simulation processing. See [Input Simulation Fields](dbCommonInput.md#input-simulation-fields) for more information on simulation mode and its fields. | Field | Summary | Type | DCT | Default | Read | Write | CA PP | | ----- | -------------------------- | ------------- | --- | ------- | ---- | ----- | ----- | | SIML | Simulation Mode Link | INLINK | Yes | | Yes | Yes | No | | SIMM | Simulation Mode | MENU [menuSimm](menuSimm.md) | No | | Yes | Yes | No | | SIOL | Simulation Input Link | INLINK | Yes | | Yes | Yes | No | | SVAL | Simulation Value | LONG | No | | Yes | Yes | No | | SIMS | Simulation Mode Severity | MENU [menuAlarmSevr](menuAlarmSevr.md) | Yes | | Yes | Yes | No | | SDLY | Sim. Mode Async Delay | DOUBLE | Yes | -1.0 | Yes | Yes | No | | SSCN | Sim. Mode Scan | MENU [menuScan](menuScan.md) | Yes | 65535 | Yes | Yes | No | ### Alarm Parameters The possible alarm conditions for multi-bit binary input direct records are the SCAN and READ alarms. These alarms are not configurable by the user since they are always of MAJOR severity. No fields exist for the mbbi direct record to have state alarms. [Alarm Fields](dbCommonRecord.md#alarm-fields) lists the fields related to alarms that are common to all record types. ## Record Support ### 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. refresh\_bits is then called to refresh all the bit fields based on a hardware value. #### process See next section. ### 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 ["Output Records"](#output-records) for information. 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. - status = read\_mbbiDirect - PACT = TRUE - `recGblGetTimeStamp()` is called. - If status is 0, then determine VAL - Set rval = RVAL - Shift rval right SHFT bits - Set VAL = RVAL - If status is 1, return 0 - If status is 2, set status = 0 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 MLST is not equal to VAL. - Monitors for RVAL are checked whenever other monitors are invoked. - NSEV and NSTA are reset to 0. 6. Scan forward link if necessary, set PACT FALSE, and return.