#NEWLINE# def encode( self , pdu ) : #NEWLINE# #INDENT# 'encode the contents of the APCI into the PDU.' #NEWLINE# if _debug : #NEWLINE# #INDENT# APCI . _debug ( 'encode %r' , pdu ) #NEWLINE# #UNINDENT# PCI . update ( pdu , self ) #NEWLINE# if ( self . apduType == ConfirmedRequestPDU . pduType ) : #NEWLINE# #INDENT# buff = ( self . apduType << 4 ) #NEWLINE# if self . apduSeg : #NEWLINE# #INDENT# buff += 8 #NEWLINE# #UNINDENT# if self . apduMor : #NEWLINE# #INDENT# buff += 4 #NEWLINE# #UNINDENT# if self . apduSA : #NEWLINE# #INDENT# buff += 2 #NEWLINE# #UNINDENT# pdu . put ( buff ) #NEWLINE# pdu . put ( ( ( encode_max_apdu_segments ( self . apduMaxSegs ) << 4 ) + encode_max_apdu_response ( self . apduMaxResp ) ) ) #NEWLINE# pdu . put ( self . apduInvokeID ) #NEWLINE# if self . apduSeg : #NEWLINE# #INDENT# pdu . put ( self . apduSeq ) #NEWLINE# pdu . put ( self . apduWin ) #NEWLINE# #UNINDENT# pdu . put ( self . apduService ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . apduType == UnconfirmedRequestPDU . pduType ) : #NEWLINE# #INDENT# pdu . put ( ( self . apduType << 4 ) ) #NEWLINE# pdu . put ( self . apduService ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( pdu . apduType == SimpleAckPDU . pduType ) : #NEWLINE# #INDENT# pdu . put ( ( self . apduType << 4 ) ) #NEWLINE# pdu . put ( self . apduInvokeID ) #NEWLINE# pdu . put ( self . apduService ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . apduType == ComplexAckPDU . pduType ) : #NEWLINE# #INDENT# buff = ( self . apduType << 4 ) #NEWLINE# if self . apduSeg : #NEWLINE# #INDENT# buff += 8 #NEWLINE# #UNINDENT# if self . apduMor : #NEWLINE# #INDENT# buff += 4 #NEWLINE# #UNINDENT# pdu . put ( buff ) #NEWLINE# pdu . put ( self . apduInvokeID ) #NEWLINE# if self . apduSeg : #NEWLINE# #INDENT# pdu . put ( self . apduSeq ) #NEWLINE# pdu . put ( self . apduWin ) #NEWLINE# #UNINDENT# pdu . put ( self . apduService ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . apduType == SegmentAckPDU . pduType ) : #NEWLINE# #INDENT# buff = ( self . apduType << 4 ) #NEWLINE# if self . apduNak : #NEWLINE# #INDENT# buff += 2 #NEWLINE# #UNINDENT# if self . apduSrv : #NEWLINE# #INDENT# buff += 1 #NEWLINE# #UNINDENT# pdu . put ( buff ) #NEWLINE# pdu . put ( self . apduInvokeID ) #NEWLINE# pdu . put ( self . apduSeq ) #NEWLINE# pdu . put ( self . apduWin ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . apduType == ErrorPDU . pduType ) : #NEWLINE# #INDENT# pdu . put ( ( self . apduType << 4 ) ) #NEWLINE# pdu . put ( self . apduInvokeID ) #NEWLINE# pdu . put ( self . apduService ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . apduType == RejectPDU . pduType ) : #NEWLINE# #INDENT# pdu . put ( ( self . apduType << 4 ) ) #NEWLINE# pdu . put ( self . apduInvokeID ) #NEWLINE# pdu . put ( self . apduAbortRejectReason ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . apduType == AbortPDU . pduType ) : #NEWLINE# #INDENT# buff = ( self . apduType << 4 ) #NEWLINE# if self . apduSrv : #NEWLINE# #INDENT# buff += 1 #NEWLINE# #UNINDENT# pdu . put ( buff ) #NEWLINE# pdu . put ( self . apduInvokeID ) #NEWLINE# pdu . put ( self . apduAbortRejectReason ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'invalid APCI.apduType' )