|
A DTS Programming Example in FORTRAN
You may download the original source files from here.
|
| |||||||||
C Example DTS front-end application
C
C Perform a simple query to the remote handler HELLO
C
C Language: VAX FORTRAN
C Date: 25-NOV-1991
program EXAMPLEFE
implicit none
C ----------------------------- Global constants -----------------------------
character*11 OUR_NAME ! Our name for the remote rtn
2 /'TestProgram'/
character*8 RECEIVER_NODE ! Receiver DTS node name
2 /'REMOTE '/
character*2 FUNCTION_CODE ! DTS function code
2 /'01'/ ! Inquiry-type transaction
character*8 REMOTE_HANDLER ! Remote user handler name
2 /'HELLO '/
integer*2 DTS_HDR_LENGTH ! DTS header length, 39 bytes
parameter (DTS_HDR_LENGTH = 39)
C ----------------- Variable definitions and field mappings ------------------
character*8 HDR_RECEIVER ! DTS header fields that must
character*2 HDR_FUNCTION_CODE ! be defined by the user
character*8 HDR_HANDLER
character*31900 USER_INPUT_DATA ! User data area
character*32000 INBUFF_S ! DTS input message buffer
logical*1 INBUFF_B(32000)
integer*2 INBUFF_LEN ! Input message actual length
! Map hdr fields and buffers
equivalence (INBUFF_S,INBUFF_B)
equivalence (INBUFF_S(22:29),HDR_RECEIVER)
equivalence (INBUFF_S(30:31),HDR_FUNCTION_CODE)
equivalence (INBUFF_S(32:39),HDR_HANDLER)
equivalence (INBUFF_S(40:),USER_INPUT_DATA)
character*2 DTS_RETURN_CODE ! DTS return code field
character*31900 USER_OUTPUT_DATA ! User data area
character*32000 OUTBUFF_S ! DTS output message buffer
logical*1 OUTBUFF_B(32000)
integer*2 OUTBUFF_LEN ! Output message actual length
! Map buffers and rc field
equivalence (OUTBUFF_S,OUTBUFF_B)
equivalence (OUTBUFF_S(1:2),DTS_RETURN_CODE)
equivalence (OUTBUFF_S(3:),USER_OUTPUT_DATA)
C ------------------------------ Begin of code -------------------------------
HDR_RECEIVER = RECEIVER_NODE ! Set receiver node name
HDR_FUNCTION_CODE = FUNCTION_CODE ! Set DTS function code
HDR_HANDLER = REMOTE_HANDLER ! Set remote handler name
USER_INPUT_DATA = OUR_NAME ! Put user data to inp buff
INBUFF_LEN = ! Input message length =
2 DTS_HDR_LENGTH+LEN(OUR_NAME) ! DTS header + user data
! Call DTS f/e service rtn
call YFIAPPC (INBUFF_B, INBUFF_LEN, OUTBUFF_B, OUTBUFF_LEN)
if ( DTS_RETURN_CODE .ne. '00' ) then ! If nonzero return status,
type 10, OUTBUFF_S(1:OUTBUFF_LEN) ! Display error message
10 format (' Call failed : ',a)
else ! If successful call,
type 20, ! Display received message
2 USER_OUTPUT_DATA(1:OUTBUFF_LEN-2)
20 format (' Message Received :',/,' ',a)
endif
END ! End of program
C ------------------------------ End of source -------------------------------
C Example DTS back-end application HELLO
C
C Return a simple 'Hello' message to the calling f/e.
C
C Language: VAX FORTRAN
C Date: 25-NOV-1991
subroutine HELLO ( INBUFF, INLEN, OUTBUFF, OUTLEN )
implicit none
C ------------------ Parameters passed in the function call ------------------
byte INBUFF(*), OUTBUFF(*) ! Message buffer areas
integer*2 INLEN, OUTLEN ! and the lengths
C ----------------------------- Global constants -----------------------------
integer*2 DTS_HDR_LENGTH ! DTS header length, 39 bytes
parameter (DTS_HDR_LENGTH = 39)
integer*2 DTS_RC_LENGTH ! DTS return code length, 2 b
parameter (DTS_RC_LENGTH = 2)
C ----------------- Variable definitions and field mappings ------------------
byte LOC_INBUFF(32000) ! Local inmsg buffer
byte LOC_OUTBUFF(32000) ! Local outmsg buffer
character*31900 USER_INPUT_DATA ! User input data area
character*31900 USER_OUTPUT_DATA ! User output data area
! Map hdr fields and buffers
equivalence (LOC_INBUFF(DTS_HDR_LENGTH+1),USER_INPUT_DATA)
equivalence (LOC_OUTBUFF(DTS_RC_LENGTH+1),USER_OUTPUT_DATA)
integer*2 LOC_LOOP ! Local loop index
C ------------------------------ Begin of code -------------------------------
do LOC_LOOP = 1, INLEN ! Copy input message to
LOC_INBUFF(LOC_LOOP) = ! local formatting buffer
2 INBUFF(LOC_LOOP)
end do
! Format response message
USER_OUTPUT_DATA(1:) = 'Hello ' // ! to the output buffer
2 USER_INPUT_DATA(1:(INLEN-DTS_HDR_LENGTH)) //
3 '. I''m your remote routine'
OUTLEN = DTS_RC_LENGTH+ ! Set output message len
2 (INLEN-DTS_HDR_LENGTH)+31 ! DTS ret code + user data
do LOC_LOOP = DTS_RC_LENGTH+1, OUTLEN ! Copy input message from
OUTBUFF(LOC_LOOP) = ! the local buffer to
2 LOC_OUTBUFF(LOC_LOOP) ! actual message buffer
end do
return ! End of subroutine task
END ! End of program
C ------------------------------ End of source -------------------------------
| ||||||||||
|