星期二, 11月 07, 2023

2006-02-23 如何檢查 UPS 連接狀況 ?


如何檢查 UPS 連接狀況 ?


	

利用 System MI _MATMATR1 取得 UPS 狀態.
 

File  : QRPGLESRC
Member: RTVUPSINF
Type  : RPGLE
Usage : CRTBNDRPG PGM(RTVUPSINF)
        由於是RPG free 格式所以需要 OS V5R1 以上才可以編譯, 可自行修改為 RPG 固定格式


     **
     **  Program . . : CBX512
     **  Description : Retrieve UPS information
     **  Author  . . : Carsten Flensburg
     **
     **
     **  Program summary
     **  ---------------
     **
     **    _MATMATR1     Materialize machine   Retrieves a broad range of system
     **                  attributes            software and hardware related
     **                                        attributes.
     **
     **  C library function:
     **    tstbts        Test bits             Tests the bit value of the bit
     **                                        located with the bit offset
     **                                        parameter, bit 0 being the
     **                                        leftmost and 64k the maximum.
     **
     **    CrtRpgMod  Module( CBX512 )
     **               DbgView( *LIST )
     **
     **    CrtPgm     Pgm( CBX512 )
     **               Module( CBX512 )
     **               ActGrp( QILE )
     **
     **
     **-- Header Specifications:  --------------------------------------------**
     H Option( *SrcStmt )  BndDir( 'QC2LE' )  DecEdit( *JobRun )
     H DftActGrp(*NO)

     **-- Global constants:
     D MMTR_MISR       c                   x'0108'
     **-- Global variables:
      * 0 = UPS battery not low
      * 1 = UPS battery low
     D UpsBatLow       s               n

      * 0 = UPS bypass not active
      * 1 = UPS bypass active
     D UpsBpsAct       s               n

      * 0 = Running on utility power
      * 1 = Running on UPS
     D UpsPwrRun       s               n

      * 0 = UPS not installed
      * 1=  UPS installed, ready for use
     D UpsInsRdy       s               n
     **-- Inz status record:
     D MMTR_0108_T     Ds                  Qualified
     D  BytPrv                       10i 0 Inz( %Size( MMTR_0108_T ))
     D  BytAvl                       10i 0
     D  MisrSts                       6a

     **-- Materialize machine attributes:
     D MatMatr         Pr                  ExtProc('_MATMATR1')
     D  Atr                       32767a          Options( *VarSize )
     D  Opt                           2a   Const
     **-- Test bit in string:
     D tstbts          Pr            10i 0 ExtProc( 'tstbts' )
     D  string                         *   Value
     D  bitofs                       10u 0 Value

      /Free

        MatMatr( MMTR_0108_T: MMTR_MISR );

        If  tstbts( %Addr( MMTR_0108_T.MisrSts ): 5 ) = 1;
          UpsBatLow = *On;
        Else;
          UpsBatLow = *Off;
        EndIf;

        Dsply 'UpsBatLow=';
        Dsply UpsBatLow;

        If  tstbts( %Addr( MMTR_0108_T.MisrSts ): 6 ) = 1;
          UpsBpsAct = *On;
        Else;
          UpsBpsAct = *Off;
        EndIf;

        Dsply 'UpsBpsAct=';
        Dsply UpsBpsAct;

        If  tstbts( %Addr( MMTR_0108_T.MisrSts ): 7 ) = 1;
          UpsPwrRun = *On;
        Else;
          UpsPwrRun = *Off;
        EndIf;

        Dsply 'UpsPwrRun=';
        Dsply UpsPwrRun;

        If  tstbts( %Addr( MMTR_0108_T.MisrSts ): 8 ) = 1;
          UpsInsRdy = *On;
        Else;
          UpsInsRdy = *Off;
        EndIf;

        Dsply 'UpsInsRdy=';
        Dsply UpsInsRdy;

        *InLr = *On;
        Return;

      /End-Free


                        



沒有留言: