def AA_7(dul): """Association abort AA-7. If receive a association request or invalid PDU while waiting for connection to close, send A-ABORT PDU State-event triggers: Sta13 + Evt6/Evt19 Parameters ---------- dul : dul.DULServiceProvider The DICOM Upper Layer Service instance for the local AE Returns ------- str ``'Sta13'``, the next state of the state machine """ primitive = A_P_ABORT() primitive.provider_reason = 0x02 # Send A-ABORT PDU. pdu = A_ABORT_RQ() pdu.from_primitive(primitive) dul.socket.send(dul.pdu.encode()) evt.trigger(dul.assoc, evt.EVT_PDU_SENT, {'pdu': dul.pdu}) return 'Sta13'
def test_conversion(self): """ Check conversion to a PDU produces the correct output """ primitive = A_P_ABORT() primitive.provider_reason = 4 pdu = A_ABORT_RQ() pdu.from_primitive(primitive) data = pdu.encode() assert data == b"\x07\x00\x00\x00\x00\x04\x00\x00\x02\x04"
def test_conversion(self): """ Check conversion to a PDU produces the correct output """ primitive = A_ABORT() primitive.abort_source = 0 pdu = A_ABORT_RQ() pdu.from_primitive(primitive) data = pdu.encode() assert data == b"\x07\x00\x00\x00\x00\x04\x00\x00\x00\x00"
def AA_1(dul: "DULServiceProvider") -> str: """Association abort AA-1. If on sending A-ASSOCIATE-RQ we receive an invalid reply, or an abort request then abort State-event triggers: Sta2 + Evt3/Evt4/Evt10/Evt12/Evt13/Evt19, Sta3/Sta5/Sta6/Sta7/Sta8/Sta9/Sta10/Sta11/Sta12 + Evt15 Parameters ---------- dul : dul.DULServiceProvider The DICOM Upper Layer Service instance for the local AE Returns ------- str ``'Sta13'``, the next state of the state machine """ # Received invalid PDU from peer or an A-ABORT primitive from local user try: primitive = dul.to_provider_queue.queue[0] if isinstance(primitive, (A_ABORT, A_P_ABORT)): primitive = dul.to_provider_queue.get(False) except (queue.Empty, IndexError): primitive = None # Send A-ABORT PDU (service-user source) and start (or restart # if already started) ARTIM timer. pdu = A_ABORT_RQ() if primitive is not None: pdu.from_primitive(primitive) else: # Reason not specified pdu.source = 0x00 pdu.reason_diagnostic = 0x00 dul._send(pdu) dul.artim_timer.restart() return "Sta13"