コード例 #1
0
ファイル: fsm.py プロジェクト: kuonanhong/pynetdicom
def AE_8(dul):
    """Association establishment action AE-8.

    On receiving association request rejection, issue A-ASSOCIATE-RJ

    State-event triggers: Sta3 + Evt8

    References
    ----------
    1. DICOM Standard 2015b, PS3.8, Table 9-7, "Associate Establishment
       Related Actions"

    Parameters
    ----------
    dul : pynetdicom.dul.DULServiceProvider
        The DICOM Upper Layer Service instance for the local AE

    Returns
    -------
    str
        Sta13, the next state of the state machine
    """
    # Send A-ASSOCIATE-RJ PDU and start ARTIM timer
    dul.pdu = A_ASSOCIATE_RJ()
    dul.pdu.from_primitive(dul.primitive)

    # Callback
    dul.assoc.acse.debug_send_associate_rj(dul.pdu)

    dul.socket.send(dul.pdu.encode())
    dul.artim_timer.start()

    return 'Sta13'
コード例 #2
0
def AE_8(dul: "DULServiceProvider") -> str:
    """Association establishment action AE-8.

    On receiving association request rejection, issue A-ASSOCIATE-RJ

    State-event triggers: Sta3 + Evt8

    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 A-ASSOCIATE (RJ) primitive from local user
    primitive = cast("A_ASSOCIATE", dul.to_provider_queue.get(False))

    # Send A-ASSOCIATE-RJ PDU and start ARTIM timer
    dul._send(A_ASSOCIATE_RJ(primitive))
    dul.artim_timer.start()

    return "Sta13"
コード例 #3
0
def AE_8(dul):
    """Association establishment action AE-8.

    On receiving association request rejection, issue A-ASSOCIATE-RJ

    State-event triggers: Sta3 + Evt8

    Parameters
    ----------
    dul : dul.DULServiceProvider
        The DICOM Upper Layer Service instance for the local AE

    Returns
    -------
    str
        ``'Sta13'``, the next state of the state machine
    """
    # Send A-ASSOCIATE-RJ PDU and start ARTIM timer
    dul.pdu = A_ASSOCIATE_RJ()
    dul.pdu.from_primitive(dul.primitive)

    dul.socket.send(dul.pdu.encode())
    evt.trigger(dul.assoc, evt.EVT_PDU_SENT, {'pdu': dul.pdu})
    dul.artim_timer.start()

    return 'Sta13'
コード例 #4
0
ファイル: fsm.py プロジェクト: xue947441187/pynetdicom
def AE_6(dul):
    """Association establishment action AE-6.

    On receiving an A-ASSOCIATE-RQ PDU from the peer then stop the ARTIM timer
    and then either

    * issue an A-ASSOCIATE indication primitive if the -RQ is acceptable or
    * issue an A-ASSOCIATE-RJ PDU to the peer and start the ARTIM timer

    This is a lower-level DUL Service Provider initiated rejection - for
    example this could be where the protocol version is checked

    State-event triggers: Sta2 + Evt6

    References
    ----------
    1. DICOM Standard 2015b, PS3.8, Table 9-7, "Associate Establishment
       Related Actions"

    Parameters
    ----------
    dul : pynetdicom.dul.DULServiceProvider
        The DICOM Upper Layer Service instance for the local AE

    Returns
    -------
    str
        Either Sta3 or Sta13, the next state of the state machine
    """
    # Stop ARTIM timer
    dul.artim_timer.stop()

    # If A-ASSOCIATE-RQ not acceptable by service dul provider
    #   Then set reason and send -RJ PDU back to peer
    if dul.pdu.protocol_version != 0x0001:
        LOGGER.error(
            "A-ASSOCIATE-RQ: Unsupported protocol "
            "version '0x%04x'", dul.pdu.protocol_version)

        # Send A-ASSOCIATE-RJ PDU and start ARTIM timer
        # dul.primitive is A_ASSOCIATE
        dul.primitive.result = 0x01
        dul.primitive.result_source = 0x02
        dul.primitive.diagnostic = 0x02

        dul.pdu = A_ASSOCIATE_RJ()
        dul.pdu.from_primitive(dul.primitive)

        dul.socket.send(dul.pdu.encode())
        evt.trigger(dul.assoc, evt.EVT_PDU_SENT, {'pdu': dul.pdu})
        dul.artim_timer.start()

        return 'Sta13'

    # If A-ASSOCIATE-RQ acceptable by service dul provider
    #   issue A-ASSOCIATE indication primitive and move to Sta3
    dul.to_user_queue.put(dul.primitive)

    return 'Sta3'
コード例 #5
0
ファイル: fsm.py プロジェクト: Jesse-Back/pynetdicom
def AE_6(dul: "DULServiceProvider") -> str:
    """Association establishment action AE-6.

    On receiving an A-ASSOCIATE-RQ PDU from the peer then stop the ARTIM timer
    and then either

    * issue an A-ASSOCIATE indication primitive if the -RQ is acceptable or
    * issue an A-ASSOCIATE-RJ PDU to the peer and start the ARTIM timer

    This is a lower-level DUL Service Provider initiated rejection - for
    example this could be where the protocol version is checked

    State-event triggers: Sta2 + Evt6

    Parameters
    ----------
    dul : dul.DULServiceProvider
        The DICOM Upper Layer Service instance for the local AE

    Returns
    -------
    str
        Either ``'Sta3'`` or ``'Sta13'``, the next state of the state machine
    """
    # Stop ARTIM timer
    dul.artim_timer.stop()

    # If A-ASSOCIATE-RQ not acceptable by service dul provider
    #   Then set reason and send -RJ PDU back to peer
    pdu = cast(A_ASSOCIATE_RQ, dul.pdu)
    primitive = cast("A_ASSOCIATE", dul.primitive)
    if pdu.protocol_version != 0x0001:
        LOGGER.error("A-ASSOCIATE-RQ: Unsupported protocol version "
                     f"'0x{pdu.protocol_version:04X}'")

        # Send A-ASSOCIATE-RJ PDU and start ARTIM timer
        # dul.primitive is A_ASSOCIATE

        primitive.result = 0x01
        primitive.result_source = 0x02
        primitive.diagnostic = 0x02

        dul.pdu = A_ASSOCIATE_RJ()
        dul.pdu.from_primitive(primitive)

        sock = cast("AssociationSocket", dul.socket)
        sock.send(dul.pdu.encode())
        evt.trigger(dul.assoc, evt.EVT_PDU_SENT, {'pdu': dul.pdu})
        dul.artim_timer.start()

        return 'Sta13'

    # If A-ASSOCIATE-RQ acceptable by service dul provider
    #   issue A-ASSOCIATE indication primitive and move to Sta3
    dul.to_user_queue.put(primitive)

    return 'Sta3'
コード例 #6
0
    def test__pdu_to_event(self):
        """Test that good PDU paramters return expected results"""
        dul = DummyDUL()
        p2e = dul._pdu_to_event

        pdu_types = [A_ASSOCIATE_RQ(), A_ASSOCIATE_AC(), A_ASSOCIATE_RJ(),
                     P_DATA_TF(), A_RELEASE_RQ(), A_RELEASE_RP(),
                     A_ABORT_RQ(), 'TEST']
        event_str = ['Evt6', 'Evt3', 'Evt4',
                     'Evt10', 'Evt12', 'Evt13',
                     'Evt16', 'Evt19']

        for pdu, evt in zip(pdu_types, event_str):
            assert p2e(pdu) == evt