HLCSDL ;ALB/MTC/SF/JC - INITIALIZE VARIABLES AND OPEN DEVICE X3.28 ;08/23/99 13:35
;;1.6;HEALTH LEVEL SEVEN;**2,44,49,57**;Oct 13, 1995
;
EN ;-- entry point for X3.28 protocol
;
;-- error trap (keepalive for disconnects)
I ^%ZOSF("OS")["DSM" N $ETRAP S $ET=""
S X="ERROR^HLCSDL",@^%ZOSF("TRAP")
EN1 ;-- check device init
;-- if device error and still running, try again
I $$INIT,$$RUN^HLCSDL2 D EXIT2 H 5 G EN1
;-- setup X3.28 parameters
I $$XSETUP G ENQ
;-- file start stats
D FILE
;-- start LLP
D START^HLCSDL1
;-- file end stats
D END
;-- exit
ENQ D EXIT
;
Q
;
INIT() ;-- check for device, open
; This fucntion will return a 1 if it fails else 0
;
N RESULT
S RESULT=0
I '$D(HLDP)&($G(%)'="") S HLDP=% ;LAUNCHED FROM VMS
I '$D(HLDP) S RESULT=1 G INITQ
D DT^DICRW
I HLDP'>0 S HLDP=$O(^HLCS(870,"B",HLDP,""))
I HLDP'>0 S RESULT=1 G INITQ
;HLDP IEN of LOGICAL LINK file #870
S HLPARM=$G(^HLCS(870,HLDP,300))
;pointer to DEVICE file
S HLDEVPTR=$P(HLPARM,U)
;-- check for valid pointer
I HLDEVPTR'>0 S RESULT=1 G INITQ
;-- check for device
S HLDEVICE=$P($G(^%ZIS(1,HLDEVPTR,0)),"^",1)
I HLDEVICE="" S RESULT=1 G INITQ
;-- open device
D MONITOR^HLCSDR2("OPEN",5,HLDP)
K ZTIO S IOP=HLDEVICE D ^%ZIS I POP D MONITOR^HLCSDR2("OPENFAIL",5,HLDP) H 3 S RESULT=1 G INITQ
;-- set up environment
S X=255 U IO X ^%ZOSF("EOFF"),^%ZOSF("RM"),^%ZOSF("TRMON")
;
INITQ Q RESULT
;
XSETUP() ;-- This function will set up all parameters required by the X3.28
; protocol.
; This function will return a 1 if it fails, else 0
;
N RESULT
S RESULT=0
;-- initialize and set defaults
;-- max message size
S HLMMS=$P(HLPARM,U,2) S:'HLMMS HLMMS=99999
;-- block size
S HLDBLOCK=$P(HLPARM,U,3) S:'HLDBLOCK HLDBLOCK=245
;-- timer a
S HLTIMA=$P(HLPARM,U,4) S:'HLTIMA HLTIMA=6
;-- timer b
S HLTIMB=$P(HLPARM,U,5) S:'HLTIMB HLTIMB=3
;-- timer d
S HLTIMD=$P(HLPARM,U,6) S:'HLTIMD HLTIMD=30
;-- timer e
S HLTIME=$P(HLPARM,U,7) S:'HLTIME HLTIME=180
N I,J,K F I=1:1 S J=$T(CTRLS+I) Q:J["END" D
.S K=$P(J,";",3),@K=$P(J,";",4)
.S HLCTRL(@K)=$P(J,";",5)
I $G(HLTRACE) K ^TMP("HLLOG",$J) S HLLOG=0
;
XSETQ Q RESULT
;
FILE ;-- file startup stats
;
D NOW^%DTC
L +^HLCS(870,HLDP,0):DTIME I '$T G FILE
;9=Time Started, 10=Time Stopped, 11=Task Number
;14=Shutdown LLP, 3=Device Type, 18=Gross Errors
I '$D(ZTSK) S ZTSK=""
S DIE="^HLCS(870,",DA=HLDP,DR="9////^S X=%;10////@;11////^S X=ZTSK;14////0;3////SX;18////@" D ^DIE K DIE,DA,DR
L -^HLCS(870,HLDP,0)
Q
;
END ;-- file stats
D NOW^%DTC
D MONITOR^HLCSDR2("SHUTDOWN",5,HLDP)
L +^HLCS(870,HLDP,0):DTIME I '$T G END
;10=Time Stopped,9=Time Started,11=Task Number
S DIE="^HLCS(870,",DA=HLDP,DR="10////^S X=%;9////@;11////@" D ^DIE K DIE,DA,DR
L -^HLCS(870,HLDP,0)
Q
;
EXIT2 ;
D ^%ZISC X ^%ZOSF("EON")
Q
EXIT ;-- exit cleanup
D ^%ZISC X ^%ZOSF("EON")
K HLMMS,HLBLOCK,HLTIMA,HLTIMB,HLTIMD,HLTIME,HLTERM,HLSOH,HLSTX,HLETB,HLETX,HLEOT,HLENQ,HLRINT,HLDLE,HLNAK,HLACK0,HLACK1,HLACK2,HLACK3,HLACK4,HLACK5,HLACK6,HLACK7
K HLDNODE,HLDEVPTR,HLDEVICE,HLRETPRM,HLDAPP,X,HLDEND,HLDSTRT,HLDVER,HLDREAD,HLDWRITE,HLDP,HLTRACE,ZTSK,HLDBSIZE
Q
;
ERROR ;
;-- on disconnect errors, trap and try to reconnect, all others,
; trap and shut down gracefully
I $$EC^%ZOSV["DSCON" D MONITOR^HLCSDR2("Disconnect",5,HLDP) H 3 G EN1
D ^%ZTER
D END G EXIT
CTRLS ;X3.28 control settings
;;HLTERM;13;<CR>
;;HLSOH;1;<SOH>
;;HLSTX;2;<STX>
;;HLETB;23;<ETB>
;;HLETX;3;<ETX>
;;HLEOT;4;<EOT>
;;HLENQ;5;<ENQ>
;;HLRINT;60;<RINT>
;;HLDLE;16;<DLE>
;;HLNAK;21;<NAK>
;;HLACK0;48;<ACK0>
;;HLACK1;49;<ACK1>
;;HLACK2;50;<ACK2>
;;HLACK3;51;<ACK3>
;;HLACK4;52;<ACK4>
;;HLACK5;53;<ACK5>
;;HLACK6;54;<ACK6>
;;HLACK7;55;<ACK7>
;;END
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHLCSDL 3838 printed Nov 22, 2024@17:06:29 Page 2
HLCSDL ;ALB/MTC/SF/JC - INITIALIZE VARIABLES AND OPEN DEVICE X3.28 ;08/23/99 13:35
+1 ;;1.6;HEALTH LEVEL SEVEN;**2,44,49,57**;Oct 13, 1995
+2 ;
EN ;-- entry point for X3.28 protocol
+1 ;
+2 ;-- error trap (keepalive for disconnects)
+3 IF ^%ZOSF("OS")["DSM"
NEW $ETRAP
SET $ETRAP=""
+4 SET X="ERROR^HLCSDL"
SET @^%ZOSF("TRAP")
EN1 ;-- check device init
+1 ;-- if device error and still running, try again
+2 IF $$INIT
IF $$RUN^HLCSDL2
DO EXIT2
HANG 5
GOTO EN1
+3 ;-- setup X3.28 parameters
+4 IF $$XSETUP
GOTO ENQ
+5 ;-- file start stats
+6 DO FILE
+7 ;-- start LLP
+8 DO START^HLCSDL1
+9 ;-- file end stats
+10 DO END
+11 ;-- exit
ENQ DO EXIT
+1 ;
+2 QUIT
+3 ;
INIT() ;-- check for device, open
+1 ; This fucntion will return a 1 if it fails else 0
+2 ;
+3 NEW RESULT
+4 SET RESULT=0
+5 ;LAUNCHED FROM VMS
IF '$DATA(HLDP)&($GET(%)'="")
SET HLDP=%
+6 IF '$DATA(HLDP)
SET RESULT=1
GOTO INITQ
+7 DO DT^DICRW
+8 IF HLDP'>0
SET HLDP=$ORDER(^HLCS(870,"B",HLDP,""))
+9 IF HLDP'>0
SET RESULT=1
GOTO INITQ
+10 ;HLDP IEN of LOGICAL LINK file #870
+11 SET HLPARM=$GET(^HLCS(870,HLDP,300))
+12 ;pointer to DEVICE file
+13 SET HLDEVPTR=$PIECE(HLPARM,U)
+14 ;-- check for valid pointer
+15 IF HLDEVPTR'>0
SET RESULT=1
GOTO INITQ
+16 ;-- check for device
+17 SET HLDEVICE=$PIECE($GET(^%ZIS(1,HLDEVPTR,0)),"^",1)
+18 IF HLDEVICE=""
SET RESULT=1
GOTO INITQ
+19 ;-- open device
+20 DO MONITOR^HLCSDR2("OPEN",5,HLDP)
+21 KILL ZTIO
SET IOP=HLDEVICE
DO ^%ZIS
IF POP
DO MONITOR^HLCSDR2("OPENFAIL",5,HLDP)
HANG 3
SET RESULT=1
GOTO INITQ
+22 ;-- set up environment
+23 SET X=255
USE IO
XECUTE ^%ZOSF("EOFF")
XECUTE ^%ZOSF("RM")
XECUTE ^%ZOSF("TRMON")
+24 ;
INITQ QUIT RESULT
+1 ;
XSETUP() ;-- This function will set up all parameters required by the X3.28
+1 ; protocol.
+2 ; This function will return a 1 if it fails, else 0
+3 ;
+4 NEW RESULT
+5 SET RESULT=0
+6 ;-- initialize and set defaults
+7 ;-- max message size
+8 SET HLMMS=$PIECE(HLPARM,U,2)
if 'HLMMS
SET HLMMS=99999
+9 ;-- block size
+10 SET HLDBLOCK=$PIECE(HLPARM,U,3)
if 'HLDBLOCK
SET HLDBLOCK=245
+11 ;-- timer a
+12 SET HLTIMA=$PIECE(HLPARM,U,4)
if 'HLTIMA
SET HLTIMA=6
+13 ;-- timer b
+14 SET HLTIMB=$PIECE(HLPARM,U,5)
if 'HLTIMB
SET HLTIMB=3
+15 ;-- timer d
+16 SET HLTIMD=$PIECE(HLPARM,U,6)
if 'HLTIMD
SET HLTIMD=30
+17 ;-- timer e
+18 SET HLTIME=$PIECE(HLPARM,U,7)
if 'HLTIME
SET HLTIME=180
+19 NEW I,J,K
FOR I=1:1
SET J=$TEXT(CTRLS+I)
if J["END"
QUIT
Begin DoDot:1
+20 SET K=$PIECE(J,";",3)
SET @K=$PIECE(J,";",4)
+21 SET HLCTRL(@K)=$PIECE(J,";",5)
End DoDot:1
+22 IF $GET(HLTRACE)
KILL ^TMP("HLLOG",$JOB)
SET HLLOG=0
+23 ;
XSETQ QUIT RESULT
+1 ;
FILE ;-- file startup stats
+1 ;
+2 DO NOW^%DTC
+3 LOCK +^HLCS(870,HLDP,0):DTIME
IF '$TEST
GOTO FILE
+4 ;9=Time Started, 10=Time Stopped, 11=Task Number
+5 ;14=Shutdown LLP, 3=Device Type, 18=Gross Errors
+6 IF '$DATA(ZTSK)
SET ZTSK=""
+7 SET DIE="^HLCS(870,"
SET DA=HLDP
SET DR="9////^S X=%;10////@;11////^S X=ZTSK;14////0;3////SX;18////@"
DO ^DIE
KILL DIE,DA,DR
+8 LOCK -^HLCS(870,HLDP,0)
+9 QUIT
+10 ;
END ;-- file stats
+1 DO NOW^%DTC
+2 DO MONITOR^HLCSDR2("SHUTDOWN",5,HLDP)
+3 LOCK +^HLCS(870,HLDP,0):DTIME
IF '$TEST
GOTO END
+4 ;10=Time Stopped,9=Time Started,11=Task Number
+5 SET DIE="^HLCS(870,"
SET DA=HLDP
SET DR="10////^S X=%;9////@;11////@"
DO ^DIE
KILL DIE,DA,DR
+6 LOCK -^HLCS(870,HLDP,0)
+7 QUIT
+8 ;
EXIT2 ;
+1 DO ^%ZISC
XECUTE ^%ZOSF("EON")
+2 QUIT
EXIT ;-- exit cleanup
+1 DO ^%ZISC
XECUTE ^%ZOSF("EON")
+2 KILL HLMMS,HLBLOCK,HLTIMA,HLTIMB,HLTIMD,HLTIME,HLTERM,HLSOH,HLSTX,HLETB,HLETX,HLEOT,HLENQ,HLRINT,HLDLE,HLNAK,HLACK0,HLACK1,HLACK2,HLACK3,HLACK4,HLACK5,HLACK6,HLACK7
+3 KILL HLDNODE,HLDEVPTR,HLDEVICE,HLRETPRM,HLDAPP,X,HLDEND,HLDSTRT,HLDVER,HLDREAD,HLDWRITE,HLDP,HLTRACE,ZTSK,HLDBSIZE
+4 QUIT
+5 ;
ERROR ;
+1 ;-- on disconnect errors, trap and try to reconnect, all others,
+2 ; trap and shut down gracefully
+3 IF $$EC^%ZOSV["DSCON"
DO MONITOR^HLCSDR2("Disconnect",5,HLDP)
HANG 3
GOTO EN1
+4 DO ^%ZTER
+5 DO END
GOTO EXIT
CTRLS ;X3.28 control settings
+1 ;;HLTERM;13;<CR>
+2 ;;HLSOH;1;<SOH>
+3 ;;HLSTX;2;<STX>
+4 ;;HLETB;23;<ETB>
+5 ;;HLETX;3;<ETX>
+6 ;;HLEOT;4;<EOT>
+7 ;;HLENQ;5;<ENQ>
+8 ;;HLRINT;60;<RINT>
+9 ;;HLDLE;16;<DLE>
+10 ;;HLNAK;21;<NAK>
+11 ;;HLACK0;48;<ACK0>
+12 ;;HLACK1;49;<ACK1>
+13 ;;HLACK2;50;<ACK2>
+14 ;;HLACK3;51;<ACK3>
+15 ;;HLACK4;52;<ACK4>
+16 ;;HLACK5;53;<ACK5>
+17 ;;HLACK6;54;<ACK6>
+18 ;;HLACK7;55;<ACK7>
+19 ;;END