Skip to content
Mike Bergsma edited this page Aug 1, 2014 · 4 revisions

HS Transaction Processing

Creating a Transaction Processing HS

In the AUTORUN directory, create two files named after the TP service. For example, for a service called TP_INFO, create the following two files:

  • AUTORUN:TP_INFO.COM
  • AUTORUN:TP_INFO.SCR**

The command procedure (TP_INFO.COM) looks like this:

$ ! AEQ\_SSP:TP\_INFO.COM  
$ !   
$ set ver  
$ set noon  
$  
$ set proc/name=TP\_INFO  
$ if .not. $status then exit  
$   
$ if f$logical ( "PROMIS\_STATUS" ) .eqs. "STARTING" then $ wait 00:05:00  
$ if f$logical ( "PROMIS\_STATUS" ) .eqs. "RUNNING" then $ @aeq\_ssp:mm  
$  
$ exit

The script file (TP_INFO.SCR) must have the following sections:

Header Section

The purpose of the header section, other than a description of the service, has the task of invoking the PROMIS application and starting HS. The PROMIS application has two parts, MEPMAIN and MUCHMAIN. It is MUCHMAIN where must of the PROMIS menu functions are found. However, when PROMIS starts up, it begins with MEPMAIN, which is just a shell that displays all the PROMIS menu functions. When the first PROMIS function is invoked, the appropriate PROMIS program containing it is loaded. The functions used in TP_INFO.SCR are all from MIUCHMAIN, so that it what is loaded.

The last line of the header section is the '##' sequence, which toggles HS to "ON".

!+ TP_INFO.SCR
!
! Description:        This script file contains embedded hs functions
!        	that perform specific PROMIS transactions for PROMIS
!        	operations at Santa Clara
!
!        	Each hs function that corresponds to a PROMIS
!        	transaction must be enabled in the CONNECT method.
! 
!        	Do not add transactions that use PROMIS functions that
!        	are not part of MUCHMAIN. (HS cannot survive
!        	between image activations.  You must use a different
!        	hs file which activates the appropriate image).
! 
!-
! The following 2 lines ensures that the MUCHMAIN image is activated. 
! (When PROMIS starts up the default image is MEPMAIN)
quit eq view
EXIT
set nopage
!
! Enable HS.  The HS program will be loaded into 
! memory.  Make sure all TP functions are enabled in the CONNECT method.

The Required Methods Section

Required HS methods are CONNECT, DISCONNECT, ABORT, MESSAGE.. These methods must be included within every TP HS. Some modifications need be made in the CONNECT method, these are the names of all the TP methods that the service provides. In the example for TP_INFO, this modfiable section is highlighted below. \

CONNECT()
{
  enable DISCONNECT ;
  enable ABORT ;
  enable MESSAGE ;

  /* TP methods */
  enable GET_EQPID_STATUS ;

  /* Enable timestamps */
  timestamp (1);

  /* Make immortal (disable death timer) */
  lifetime (0) ;

  /* Wait for requests */
  idle () ;
}

EXIT_FUNCTION() { pexec("EXIT") ; }
QUIT_FUNCTION() { pexec("QUIT") ; }  
MESSAGE() { return ; }
ABORT() { exit(); }
DISCONNECT() { exit(); }

The Services Section

The services section contain the names of the methods that the TP HS serves. These methods names are case-sensitive, uppercase names are merely a convention. In the TP_INFO example, the service is called "GET_EQPID_STATUS". Another convention that is helpful is to add another method called DONE_<service>, which helps to streamline the program code in how the service responds to queries.

GET_EQPID_STATUS()
{
  /* Required tokens and values:
   *
   *   EQPID
   *
   * Reply Tokens:
   *   STATUS   - PROMIS equipment status
   */

  /* *****************************************************************
   *                         INITIALIZE
   *******************************************************************/
  /* Check arguments */
  if ( !exists ( EQPID ) || !count ( EQPID ) )
    return DONE_GET_EQPID_STATUS ({ "%PROMIS: Invalid args ", args } ) ;

  /* *****************************************************************
   *                   PERFORM EQUIPMENT STATUS
   *******************************************************************/
  EQPID = toupper trim EQPID ;
  pclose("eqps");
  ret = pget("eqps.eqpskey","ge",EQPID) ;
  if ( !ret || 
       trim eqps.eqpid != EQPID ||
       eqps.rectype != "C" )
    return DONE_GET_EQPID_STATUS ( { "%PROMIS: no such equipment: ",EQPID });
   
  return DONE_GET_EQPID_STATUS ( eqps.status ) ;
}

DONE_GET_EQPID_STATUS( str TEXT )
{
  puts TEXT ;
  EXIT_FUNCTION() ;
  QUIT_FUNCTION() ;
  undef EQPID ;
  return TEXT ;
}

Trailer Section

This section is required to "bootstrap" the program into memory, and start the service running. It also provides an "exit" from the program in case of an error in the HS exist.

! The CONNECT method must be enabled after the program loads.
enable CONNECT ;
! Begin the HS program.  
CONNECT();
!
! If we get here, then there's either an error in the HS or the
! HS has called the exit() function. At this point, we are
! back executing a normal PROMIS script, and so we should exit MUCHMAIN
QUIT RETURN

Starting a TP HS.

To start a TP HS, a command procedure is required. For example, to start the TP_INFO service, the following command is used.

$ @AEQ_SSP:AUTOSTART TP_INFO

To start a TP HS service automatically, edit the AEQ_SSP:CONFIG.COM procedure file and add the name of the service to the services section. Once added, the command:

$ @AEQ_SSP:AUTOSTART

will automatically start all the services specified in AEQ_SSP:CONFIG.COM, including the ROOT HS.

Stopping a TP HS.

To stop a TP HS, a command procedure is required. For example, to stop the TP_INFO service, the following command is used.

$ @AEQ_SSP:AUTOSTOP TP_INFO

To stop a TP HS service automatically, edit the AEQ_SSP:CONFIG.COM procedure file and add the name of the service to the services section. Once added, the command:

$ @AEQ_SSP:AUTOSTOP

will automatically stop all the services specified in AEQ_SSP:CONFIG.COM, including the ROOT HS.

Testing a TP HS

The easiest way to test the functionality of a TP HS service is to use a client HS.

For example, to invoke the GET_EQPID_STATUS function listed above in the TP_INFO example, start a HS session and type the following commands:

EQPID = "CANON-I1" ;  
status = query("TP\_INFO@promisNode","GET\_EQPID\_STATUS",{&EQPID});  
puts status ;

If the status variable does not come back "$ACK", then something went wrong. You can type the contents of the TP HS service log file, its in AUTOLOG. For example, the TP_INFO log is:

AUTOLOG:TP_INFO.LOG

Clone this wiki locally