- ABSPOSAA ; IHS/FCS/DRS - JWS, ; [ 09/12/2002 10:05 AM ]
- ;;1.0;PHARMACY POINT OF SALE;**3**;JUN 21, 2001;Build 38
- Q
- ; $$CONNECT(DIALOUT) - initialize modem and dial
- ; Called from ABSPOSAQ from ABSPOSAM
- ; Various errors can be returned
- ; Future: put a field in the 9002313.55 record to put these
- ; stages as you progress through establishing the connection.
- ; Future: tap into that field when constructing display message
- ; for the data entry / status display screen.
- ; That is, show more than just "Waiting to transmit" - show
- ; it going through stages like "Initializing modem",
- ; "Dialing", "Waiting for remote connect", etc.
- ; And tack on "Failed while " in front, when something goes wrong.
- ;
- CONNECT(DIALOUT) ;EP -
- ; Open the device
- N RET
- S RET=$$OPEN^ABSPOSAB(DIALOUT)
- I RET Q 20999_",OPEN^ABSPOSAB(),"_RET
- S RET=$$STATUS(DIALOUT) I RET Q "20998,STATUS^"_$T(+0)_","_RET_",0"
- ;
- ;Flush input buffer
- S RET=$$FLUSH^ABSPOSAB(DIALOUT)
- I RET Q 20997_",FLUSH^ABSPOSAB(),"_RET_",1"
- S RET=$$STATUS(DIALOUT) I RET Q "20998,STATUS^"_$T(+0)_","_RET_",1"
- ;
- ; if it's a direct T1 line connection, we are done - return success
- ;
- I $$T1DIRECT^ABSPOSA(DIALOUT) Q 0
- ;
- ; First, ATZ command to reset the modem
- ; And flush the buffer, too.
- S RET=$$ATZ^ABSPOSAB(DIALOUT)
- I RET Q 20008_",ATZ^ABSPOSAB(),"_RET
- S RET=$$STATUS(DIALOUT) I RET Q "20998,STATUS^"_$T(+0)_","_RET_",2"
- S RET=$$FLUSH^ABSPOSAB(DIALOUT)
- I RET Q 20997_",FLUSH^ABSPOSAB(),"_RET_",2"
- S RET=$$STATUS(DIALOUT) I RET Q "20998,STATUS^"_$T(+0)_","_RET_",3"
- ;
- ; Then send the initialization string, and flush
- ;
- S RET=$$INIMODEM^ABSPOSAB(DIALOUT)
- I RET Q 20009_",INIMODEM^ABSPOSAB(),"_RET
- S RET=$$STATUS(DIALOUT) I RET Q "20998,STATUS^"_$T(+0)_","_RET_",4"
- S RET=$$FLUSH^ABSPOSAB(DIALOUT)
- I RET Q 20997_",FLUSH^ABSPOSAB(),"_RET_",3"
- S RET=$$STATUS(DIALOUT) I RET Q "20998,STATUS^"_$T(+0)_","_RET_",5"
- ;
- ; Diagnostics: query the modem for its status
- ;
- S RET=$$MODEMSTS^ABSPOSAB(DIALOUT)
- I RET Q 20997_",MODEMSTS^ABSPOSAB(),"_RET_",31"
- S RET=$$STATUS(DIALOUT) I RET Q "20998,STATUS^"_$T(+0)_","_RET_",32"
- S RET=$$FLUSH^ABSPOSAB(DIALOUT)
- I RET Q 20997_",FLUSH^ABSPOSAB(),"_RET_",31"
- S RET=$$STATUS(DIALOUT) I RET Q "20998,STATUS^"_$T(+0)_","_RET_",33"
- ;
- ; Now we can dial the phone, and flush
- ;
- S RET=$$DIAL^ABSPOSAB(DIALOUT)
- I RET Q 20010_",DIAL^ABSPOSAB(),"_RET
- S RET=$$STATUS(DIALOUT) I RET Q "20998,STATUS^"_$T(+0)_","_RET_",6"
- S RET=$$FLUSH^ABSPOSAB(DIALOUT)
- I RET Q 20997_",FLUSH^ABSPOSAB(),"_RET_",4"
- S RET=$$STATUS(DIALOUT) I RET Q "20998,STATUS^"_$T(+0)_","_RET_",7"
- Q 0
- ;
- STATUS(DIALOUT) ;check status of IO
- ; Always returns 0 (OK) for direct-connect Modem.
- ; Returns $ZB value for terminal server.
- ; Development: $$STATRPT^ABSPOSAZ, $$GETSTAT^ABSPOSAZ may be useful
- ;
- I '$$TCP^ABSPOSA(DIALOUT) Q 0 ; relevant only to term server and T1
- ; if last operation timed out (-3), that's okay
- ; maybe we should also skim past "end of input" (-1), too
- N IO S IO=$$IO^ABSPOSA(DIALOUT)
- U IO N ZB S ZB=$ZB S:ZB=-3 ZB=0 Q ZB
- ABSPOSAA ; IHS/FCS/DRS - JWS, ; [ 09/12/2002 10:05 AM ]
- +1 ;;1.0;PHARMACY POINT OF SALE;**3**;JUN 21, 2001;Build 38
- +2 QUIT
- +3 ; $$CONNECT(DIALOUT) - initialize modem and dial
- +4 ; Called from ABSPOSAQ from ABSPOSAM
- +5 ; Various errors can be returned
- +6 ; Future: put a field in the 9002313.55 record to put these
- +7 ; stages as you progress through establishing the connection.
- +8 ; Future: tap into that field when constructing display message
- +9 ; for the data entry / status display screen.
- +10 ; That is, show more than just "Waiting to transmit" - show
- +11 ; it going through stages like "Initializing modem",
- +12 ; "Dialing", "Waiting for remote connect", etc.
- +13 ; And tack on "Failed while " in front, when something goes wrong.
- +14 ;
- CONNECT(DIALOUT) ;EP -
- +1 ; Open the device
- +2 NEW RET
- +3 SET RET=$$OPEN^ABSPOSAB(DIALOUT)
- +4 IF RET
- QUIT 20999_",OPEN^ABSPOSAB(),"_RET
- +5 SET RET=$$STATUS(DIALOUT)
- IF RET
- QUIT "20998,STATUS^"_$TEXT(+0)_","_RET_",0"
- +6 ;
- +7 ;Flush input buffer
- +8 SET RET=$$FLUSH^ABSPOSAB(DIALOUT)
- +9 IF RET
- QUIT 20997_",FLUSH^ABSPOSAB(),"_RET_",1"
- +10 SET RET=$$STATUS(DIALOUT)
- IF RET
- QUIT "20998,STATUS^"_$TEXT(+0)_","_RET_",1"
- +11 ;
- +12 ; if it's a direct T1 line connection, we are done - return success
- +13 ;
- +14 IF $$T1DIRECT^ABSPOSA(DIALOUT)
- QUIT 0
- +15 ;
- +16 ; First, ATZ command to reset the modem
- +17 ; And flush the buffer, too.
- +18 SET RET=$$ATZ^ABSPOSAB(DIALOUT)
- +19 IF RET
- QUIT 20008_",ATZ^ABSPOSAB(),"_RET
- +20 SET RET=$$STATUS(DIALOUT)
- IF RET
- QUIT "20998,STATUS^"_$TEXT(+0)_","_RET_",2"
- +21 SET RET=$$FLUSH^ABSPOSAB(DIALOUT)
- +22 IF RET
- QUIT 20997_",FLUSH^ABSPOSAB(),"_RET_",2"
- +23 SET RET=$$STATUS(DIALOUT)
- IF RET
- QUIT "20998,STATUS^"_$TEXT(+0)_","_RET_",3"
- +24 ;
- +25 ; Then send the initialization string, and flush
- +26 ;
- +27 SET RET=$$INIMODEM^ABSPOSAB(DIALOUT)
- +28 IF RET
- QUIT 20009_",INIMODEM^ABSPOSAB(),"_RET
- +29 SET RET=$$STATUS(DIALOUT)
- IF RET
- QUIT "20998,STATUS^"_$TEXT(+0)_","_RET_",4"
- +30 SET RET=$$FLUSH^ABSPOSAB(DIALOUT)
- +31 IF RET
- QUIT 20997_",FLUSH^ABSPOSAB(),"_RET_",3"
- +32 SET RET=$$STATUS(DIALOUT)
- IF RET
- QUIT "20998,STATUS^"_$TEXT(+0)_","_RET_",5"
- +33 ;
- +34 ; Diagnostics: query the modem for its status
- +35 ;
- +36 SET RET=$$MODEMSTS^ABSPOSAB(DIALOUT)
- +37 IF RET
- QUIT 20997_",MODEMSTS^ABSPOSAB(),"_RET_",31"
- +38 SET RET=$$STATUS(DIALOUT)
- IF RET
- QUIT "20998,STATUS^"_$TEXT(+0)_","_RET_",32"
- +39 SET RET=$$FLUSH^ABSPOSAB(DIALOUT)
- +40 IF RET
- QUIT 20997_",FLUSH^ABSPOSAB(),"_RET_",31"
- +41 SET RET=$$STATUS(DIALOUT)
- IF RET
- QUIT "20998,STATUS^"_$TEXT(+0)_","_RET_",33"
- +42 ;
- +43 ; Now we can dial the phone, and flush
- +44 ;
- +45 SET RET=$$DIAL^ABSPOSAB(DIALOUT)
- +46 IF RET
- QUIT 20010_",DIAL^ABSPOSAB(),"_RET
- +47 SET RET=$$STATUS(DIALOUT)
- IF RET
- QUIT "20998,STATUS^"_$TEXT(+0)_","_RET_",6"
- +48 SET RET=$$FLUSH^ABSPOSAB(DIALOUT)
- +49 IF RET
- QUIT 20997_",FLUSH^ABSPOSAB(),"_RET_",4"
- +50 SET RET=$$STATUS(DIALOUT)
- IF RET
- QUIT "20998,STATUS^"_$TEXT(+0)_","_RET_",7"
- +51 QUIT 0
- +52 ;
- STATUS(DIALOUT) ;check status of IO
- +1 ; Always returns 0 (OK) for direct-connect Modem.
- +2 ; Returns $ZB value for terminal server.
- +3 ; Development: $$STATRPT^ABSPOSAZ, $$GETSTAT^ABSPOSAZ may be useful
- +4 ;
- +5 ; relevant only to term server and T1
- IF '$$TCP^ABSPOSA(DIALOUT)
- QUIT 0
- +6 ; if last operation timed out (-3), that's okay
- +7 ; maybe we should also skim past "end of input" (-1), too
- +8 NEW IO
- SET IO=$$IO^ABSPOSA(DIALOUT)
- +9 USE IO
- NEW ZB
- SET ZB=$ZB
- IF ZB=-3
- SET ZB=0
- QUIT ZB