	.title	ACKQ  ACKNOWLEDGE MESSAGE READ
	.IDENT	/1.2/
;.begin.doc ************************** begin.doc
;  
; .c ;MODULE
; .c ;^&ACKQ\&
; .nf
; .x ACKQ>Defined
; Source:ACKQ.MAC
; TO BECOME PART OF LIBRARY:QUEUE.OLB
; Designer           :EARL LAKIA
; Author             :DAVE LUECK
;             Inland Steel
;             Process Automation Department
;             3210 Watling St.  MS 2-465
;             East Chicago, IN  46312
;  
; Date of last update:18-MAY-1987
; Revision level     :1.2
;  
; .C ;Formal Parameter List
; Receives:
;  
;    LUN                        INTEGER*2
;                               LOGICAL UNIT NUMBER ASSIGNED TO ZQ0:
;     
;    EFN                        INTEGER*2
;                               EVENT FLAG TO BE USED FOR I/O SYNC
;    
;    MSGID                      CHARACTER*16  (BYTE(16))
;                               MESSAGE ID OF LIST HEAD TO READ
;   
;    RNA                        INTEGER*2
;                               READ NOT ACKNOWLEGED POINTER
;                               (RETURNED FROM ACP/DRIVER IN I/O STATUS 
;                                BLOCK)
;   
; Returns:
;  
;    ACKQ                       INTEGER*2                               
;                               FUNCTION VALUE RETURN STATUS OF THE 
;                               CONNECT
;  
; Accesses common(s):
;  
; Accesses file(s):
;  
; Other modules referenced:
; .SK
; .fill
; .SK
; Description:
; .sk    
; 	This subroutine allows a task to acknowledge the reading of
; a message in a message id queue in the Manufacturing Automation Queue.  
; The return status is returned as the value of the function subroutine.  The
; calling sequence is:
; .sk
; .tp 40
; .nofill
; 	INTEGER*2 STATUS     ! RETURN STATUS
; 	BYTE STATB(2)
; 	EQUIVALENCE(STATUS,STATB) ! BYTE ADDRESSABLE STATUS
; 	CHARACTER*16 MSGID   ! MESSAGE ID
; 	INTEGER*2 LUN	     ! LUN ASSIGNED TO ZQ0:
; 	INTEGER*2 IEFN	     ! EVENT FLAG
; 	INTEGER*2 RNA	     ! READ BUT NOT ACKNOWLEDGED POINTER
; 	INTEGER*2 QUESUC     ! SUCESSFUL QUE STATUS
; C
; 	DATA QUESUC/"401/
; 	DATA LUN/1/	     ! LOGICAL UNIT NUMBER
; 	DATA IEFN/1/	     ! EVENT FLAG FOR I/O SYNC
; C
; 	MSGID='DUMMY ID'  ! OUR MESSAGE ID
; C
; C ASSIGN A LUN TO THE PSEUDO DEVICE FOR THE QUEUE
; C
; 	CALL ASSIGN(LUN,'ZQ0:')
; C
; C ACKNOWLEDGE THE READ
; C
; 	STATUS=ACKQ(LUN,IEFN,MSGID,RNA)
; C
; 	IF(STATUS .NE. QUESUC)THEN
; 		TYPE *,' BAD QUEUE STATUS ON MESSAGE ACKNOWLEDGE'
; 		TYPE *,' DIRECTIVE STATUS: ',STATB(1)
; 		TYPE *,' I/O STATUS: ',STATB(2)
; 		CALL EXIT
; 	ELSE
; 		TYPE *,' ACKNOWLEDGE SUCCESSFUL'
; 	ENDIF
; .FILL
; .SK
; 	Possible error codes:
; .LIST 1,' '
; .le;Bad directive status (possibly device not mounted, etc.)
; (upper byte will be zero)
; .le;Bad I/O status (R0 lower byte= 1,  upper byte= I/O status)
; .LE;IE.UKN (-97) -- Message id does not exist.
; .le;IE.PNT (-71) -- No message in this queue needs to be acknowledged.
; .le;IE.SNC (-35) -- The wrong message is being acknowledged.
; .els
; end.doc ****************************** end.doc  
	.PAGE
	.MCALL	DIR$
	.MCALL	QIOW$
;
;	 0(R5)= NUMBER OF ARGUMENTS
;	 2(R5)= LUN
;	 4(R5)= EFN
;	 6(R5)= ADDRESS OF MESSAGE ID NAME
;	10(R5)= READ BUT NOT ACK POINTER
;
; 	STATUS=ACKQ(LUN,IEFN,MSGID,RNA)
;
;
	.PSECT	Q$CODE,RO,I,CON
ACKQ::
	CMP	#4,(R5)+	; CORRECT NUMBER OF ARGUMENTS
	BEQ	10$		; YES
	TRAP	<128.+80.>	; FORTRAN OTS TRAP FOR ILLEGAL NUMBER
				; OF ARGUMENTS
	RETURN
10$:
	MOVB	@(R5)+,DOIO+Q.IOLU	; GET LOGICAL UNIT NUMBER
	MOV	@(R5)+,DOIO+Q.IOEF	; EVENT FLAG
	MOV	(R5)+,DOIO+Q.IOPL	; GET MESSAGE ID NAME ADDRESS
	MOV	#16.,DOIO+Q.IOPL+2 	; BYTE COUNT OF THE MESSAGE ID
	MOV	@(R5)+,DOIO+Q.IOPL+4	; RNA
;
; NOW DO THE QIO 
;
	DIR$	#DOIO		; DO THE I/O
	BCC	30$		; DIRECTIVE ACCEPTED
	MOVB	$DSW,R0		; SIGN EXTEND BAD DIRECTIVE STATUS
	BIC	#177400,R0	; CLEAR I/O STATUS
	RETURN
;
; DIRECTIVE RECEIVED, RETURN THE I/O STATUS
;
30$:
	MOVB	IOSB,R0		; I/O STATUS
	SWAB	R0		; MOVE I/O STATUS TO UPPER BYTE
	CLRB	R0		; CLEAR LOW BYTE
	BISB	$DSW,R0		; MERGE IN THE DIRECTIVE STATUS INLOWER BYTE
	RETURN
	.PAGE
	.PSECT	Q$DATA,RW,CON,D
;
; .le;P1= Address of message id buffer (16 bytes long)
; .le;P2= Byte count of message id (16 bytes)
; .le;P3= RNA
;
DOIO:
	QIOW$	IO.ACW,,,,IOSB,,
;
IOSB:
	.WORD	0,0
	.END
