h hdftactgrp(*no) d MatMAtr pr extproc('_MATMATR1') d RcvVar 1a options(*varsize) d Format 2a const d MchInfo ds qualified d BytPrv 10i 0 inz(%size(MchInfo)) d BytAvl 10i 0 d SrlNbr 8a d MchUPS ds qualified d BytPrv 10i 0 inz(%size(MchUPS)) d BytAvl 10i 0 d CurrIPLType 1a d PanelStatus1 1a d PanelStatus2 1a d Reserved5 5a d MostRecentIPLType... d 1a /free MatMatr(MchInfo :x'0004'); dsply ('Serial number . . . ' + MchInfo.SrlNbr); MatMatr(MchUPS :x'0168'); TestBytes(MchUPS.PanelStatus1); *inlr = *on; return; /end-free P TestBytes B D TestBytes PI D Hexval 1 CONST *- Bitwise processing from bmeyers... *--http://www.bmeyers.net/ *-- faqs/15-faqs/55-using-bitand-to-test-bits * // ---------------------------------------- Constants // Bit0 = 10000000 // Bit1 = 01000000 // Bit2 = 00100000 // Bit3 = 00010000 // Bit4 = 00001000 // Bit5 = 00000100 // Bit6 = 00000010 // Bit7 = 00000001 D Bit0 C X'80' D Bit1 C X'40' D Bit2 C X'20' D Bit3 C X'10' D Bit4 C X'08' D Bit5 C X'04' D Bit6 C X'02' D Bit7 C X'01' /Free // My notes... // Bit0 = hex '80' = '1000 0000' // Bit1 = hex '40' = '0100 0000' // Bit2 = hex '20' = '0010 0000' // Bit3 = hex '10' = '0001 0000' // Bit4 = hex '08' = '0000 1000' // Bit5 = hex '04' = '0000 0100' // Bit6 = hex '02' = '0000 0010' // Bit7 = hex '01' = '0000 0001' // If %bitand(Hexval:Bit0) = Bit0 will // be true if the first bit of the parm coming // in is a '1'. All other bits will be 0 // in the result because Bit0 has only 0's // in all other bits. The only way the // resulting bits can be '1' is if both the // incoming field and the base field have a '1' // in the same bit. // So %bitand('10101010':'10000000') = '10000000' is // true. %bitand('00010101':'10000000') = '10000000' is // false // Uninterrupted power supply installed If %Bitand(Hexval:Bit0) = Bit0; Dsply ('Bit 0 is *On: UPS is Attached'); Else; Dsply ('Bit 0 is *Off: UPS is NOT Attached'); Endif; // Utility power failed, running on UPS If %Bitand(Hexval:Bit1) = Bit1; Dsply 'Bit 1 is *On: Utility power failed, running on UPS'; Else; Dsply 'Bit 1 is *Off: Running on Utility power'; Endif; // Uninterrupted power supply (UPS) bypass active If %Bitand(Hexval:Bit2) = Bit2; Dsply 'Bit 2 is *On: UPS bypass active'; Else; Dsply 'Bit 2 is *Off: UPS bypass NOT active'; Endif; // Uninterrupted power supply (UPS) battery low If %Bitand(Hexval:Bit3) = Bit3; Dsply 'Bit 3 is *On: UPS battery low'; Else; Dsply 'Bit 3 is *Off: UPS battery NOT low'; Endif; // Auto key mode If %Bitand(Hexval:Bit4) = Bit4; Dsply 'Bit 4 is *On: Key mode is Auto'; Else; Dsply 'Bit 4 is *Off: Key mode in NOT Auto'; Endif; // Normal key mode If %Bitand(Hexval:Bit5) = Bit5; Dsply 'Bit 5 is *On: Normal key mode'; Else; Dsply 'Bit 5 is *Off: NOT Normal key mode'; Endif; // Manual key mode If %Bitand(Hexval:Bit6) = Bit6; Dsply 'Bit 6 is *On: Manual key mode'; Else; Dsply 'Bit 6 is *Off: NOT Manual key mode'; Endif; // Secure key mode If %Bitand(Hexval:Bit7) = Bit7; Dsply 'Bit 7 is *On: Secure key mode'; Else; Dsply 'Bit 7 is *Off: NOT Secure key mode'; Endif; Return; /End-free P TestBytes e