Writing a power-handling program

A power-handling program should be activated at each IPL and remain active at all times. It should be accounted for in the activity level available in work management subsystem specifications.

The message queue that is specified in QUPSMSGQ is used for uninterruptible power supply message processing. The program normally allocates the queue by specifying the command:
ALCOBJ OBJ(xxx/yyy *MSGQ *EXCL)
When a message arrives, the critical messages to process are:

You can choose to ignore the other messages.

Your program can handle a brief power interruption without doing any unique processing. For example, when the CPF1816 message arrives, you can set a switch in your program that indicates that the message occurred. The program might then perform a RCVMSG with WAIT(10) to cause a time-out in 10 seconds. If the CPF1817 message is received before the time-out occurs, you can reset the switch and perform no other action.

Your program can prepare for a normal shut down if power is not restored after a brief time period. For example, if you have remote workstations that are still active, you may want to send them a message requesting they sign off quickly. You may want to issue ENDSBS OPTION(*CNTRLD) to prevent new workstations from signing on or new batch work from beginning. If you have batch jobs running, you may want to end them with the following command:
ENDJOB OPTION(*CNTRLD)

This sets an indicator to end the job. Some higher level languages and the control language allow you to test within a program to see if a controlled ENDJOB was specified. If the program does not end itself, the default on ENDJOB (30 seconds) is used.

You can set a second timer in your program, such as RCVMSG WAIT(120). If utility power has not been restored, you can issue the PWRDWNSYS OPTION(*IMMED) command. The wait time should be specified based on your battery time and the time that is required for a power-down.

If you name a message queue for the QUPSMSGQ system value and *NOMAX for QUPSDLYTIM, the following conditions apply: If not, the system assumes that no power handling program exists, and the system will be powered down.
Note: When the system has been placed in a restricted state (for example, ENDSBS *ALL), your uninterruptible power supply handling program will no longer be active. For this reason, it is necessary to prepare an alternate method of dealing with your uninterruptible power supply and any possible power interruptions that may occur while your system is in a restricted state.

For example, when performing a SAVSYS (Save System) or RCLSTG (Reclaim Storage), your uninterruptible power supply program will no longer be active once all subsystems have been terminated. Only a single workstation job will be active. You can perform one of the following actions as an alternative:

  1. After all subsystems have been ended, from the command line change the mode for the message queue specified in system value QUPSMSGQ to *BREAK. This will cause all uninterruptible power supply messages to be sent as break messages to the user signed on to that workstation. With this method the user will manually decide what to do should a power failure occur.
  2. Change the system value QUPSDLYTIM to some value other than *NOMAX (for example, the number of minutes you want the uninterruptible power supply to ride out the power failure). This method will prevent the system from performing an immediate quick shut down. However, if a power failure occurs, a quick shut down will be performed if the power failure lasts longer than the value specified for the system value QUPSDLYTIM.
  3. Change your existing uninterruptible power supply handling program for use as a BREAK HANDLING program which may be used while the system is in a restricted state. This can be done by creating a second version of your uninterruptible power supply program that does not allocate the message queue specified in system value QUPSMSGQ. (In other words, do not use the ALCOBJ command.) To utilize this program while in a restricted state, before starting a dedicated function such as SAVSYS, enter the command:
    CHGMSGQ MSGQ(LIB/MSGQ) DLVRY(*BREAK)
    PGM(LIB/PGM)

    where (LIB/MSGQ) is the name the message queue specified in system value QUPSMSGQ, and (PGM/LIB) is the name of your modified uninterruptible power supply handling program. Now, should a power failure occur, the power failure message will be handled by the break handling program, even while a function such as SAVSYS is running. To deactivate the break handling program either have the user sign off or enter:

    CHGMSGQ MSGQ(LIB/MSGQ) DLVRY(*HOLD)
    PGM(*DSPMSG)

    Once you have deactivated the break handling program, you should immediately start your subsystems and your normal uninterruptible power supply handling program.

IBM grants you a nonexclusive copyright license to use all programming code examples from which you can generate similar function tailored to your own specific needs.

Start of changeSUBJECT TO ANY STATUTORY WARRANTIES WHICH CANNOT BE EXCLUDED, IBM, ITS PROGRAM DEVELOPERS AND SUPPLIERS MAKE NO WARRANTIES OR CONDITIONS EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT, REGARDING THE PROGRAM OR TECHNICAL SUPPORT, IF ANY. End of change

Start of changeUNDER NO CIRCUMSTANCES IS IBM, ITS PROGRAM DEVELOPERS OR SUPPLIERS LIABLE FOR ANY OF THE FOLLOWING, EVEN IF INFORMED OF THEIR POSSIBILITY: End of change

Start of change
  1. LOSS OF, OR DAMAGE TO, DATA;
  2. DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES, OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES; OR
  3. LOST PROFITS, BUSINESS, REVENUE, GOODWILL, OR ANTICIPATED SAVINGS.
End of change

Start of changeSOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF DIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, SO SOME OR ALL OF THE ABOVE LIMITATIONS OR EXCLUSIONS MAY NOT APPLY TO YOU.End of change