Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: INHFTM1

INHFTM1.m

Go to the documentation of this file.
  1. INHFTM1(INBPN,INHSRVR) ; DGH,FRW ; 3 Feb 93 14:54; Format Controller background process - server [ 06/22/2001 2:28 PM ]
  1. ;;3.01;BHL IHS Interfaces with GIS;;July 1, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. EN ;Main entry point
  1. ;INPUT:
  1. ; INHSRVR - server number
  1. ; INBPN - ien for output controller
  1. ;LOCAL:
  1. ; DA - transaction to process (ien) in ^INLHFTSK
  1. ; INHANG - time to hang after processing a task,
  1. ; from file #4002 field #.05
  1. ; INHER - error message
  1. ; INHMWAIT - maximum time a server should wait for
  1. ; something to process before shutting down,
  1. ; from file #4002 field #2.04
  1. ; INHWAIT - time since a trascation was processed
  1. ; MODE - always set to zero (0), used in BACK^INHF
  1. ;
  1. L +^INRHB("RUN","SRVR",INBPN,INHSRVR):5 E Q
  1. X $G(^INTHOS(1,2))
  1. Q:'$G(INBPN)!'$G(INHSRVR)!'$$RUN^INHFTM
  1. K INHER S X="ERROR^INHFTM1",@^%ZOSF("TRAP")
  1. S ^INRHB("RUN","SRVR",INBPN,INHSRVR)=$H
  1. ;*** REPLACE WITH STANDARD CALL
  1. S U="^",DUZ=.5,DUZ(0)="@",IO=""
  1. S X=$$PRIO^INHB1 X:X ^%ZOSF("PRIORITY")
  1. ;Set up control variables
  1. S INHANG=$P($G(^INRHSITE(1,0)),U,5) S:'INHANG INHANG=10
  1. S INHMWAIT=$P($G(^INRHSITE(1,2)),U,4) S:'INHMWAIT INHMWAIT=60
  1. S MODE=0,INHWAIT=-INHANG
  1. ;
  1. LOOP ;Main loop to process transactions
  1. S INHWAIT=INHWAIT+INHANG
  1. I '$$RUN^INHFTM!(INHWAIT>INHMWAIT) G HALT
  1. S ^INRHB("RUN","SRVR",INBPN,INHSRVR)=$H
  1. L +^INLHFTSK("AH"):3 E H INHANG G LOOP
  1. S DA=$$NEXTDA I 'DA L -^INLHFTSK("AH") H INHANG G LOOP
  1. K ^INLHFTSK("AH",PRIO,H,DA)
  1. L -^INLHFTSK("AH")
  1. S INHWAIT=0
  1. D JOB H INHANG G LOOP
  1. Q
  1. ;
  1. JOB ;Run formatter
  1. ;Any variables that are needed by the server program (^INHFTM1) should be NEWed prior to calling ^INHF
  1. N INHANG,INHMWAIT,INHWAIT,MODE,INBPN,INHSRVR
  1. D BACK^INHFTM(DA)
  1. Q
  1. ;
  1. NEXTDA() ;Get next transaction off queue
  1. ;OUTPUT:
  1. ; function value - next transaction to process
  1. ;
  1. S DAY=+$H,TIME=$P($H,",",2),DA=""
  1. S P="" F S P=$O(^INLHFTSK("AH",P)) Q:DA!(P="") D
  1. .S H=$O(^INLHFTSK("AH",P,"")) Q:H=""
  1. .S ND=+H,NT=$P(H,",",2) Q:ND>DAY!(NT>TIME&(ND=DAY))
  1. .S DA=$O(^INLHFTSK("AH",P,H,"")),PRIO=P
  1. Q +DA
  1. ;
  1. ERROR ;Error module for server
  1. S X="HALT^INHFTM1",@^%ZOSF("TRAP")
  1. X ^INTHOS(1,3)
  1. S INHER(1)=$S($D(INHER)#2:INHER,1:$$ERRMSG^INHU1)
  1. S INHER(2)="in format controller background server for task "_$G(DA)
  1. ;***DA may not be the transaction being processed - it may have been the previous transaction processed
  1. S %="" I +$G(DA) S %=$G(^INLHFTSK(DA,0))
  1. D ENF^INHE($P(%,U,1),$P(%,U,2),$P(%,U,3),"",.INHER)
  1. ;
  1. HALT ;Halt process
  1. K ^INRHB("RUN","SRVR",INBPN,INHSRVR)
  1. L -^INRHB("RUN","SRVR",INBPN,INHSRVR)
  1. H
  1. ;