pynetdicom.ae.ApplicationEntity

class pynetdicom.ae.ApplicationEntity(ae_title=b'PYNETDICOM', port=0)[source][source]

Represents a DICOM Application Entity (AE).

An AE may be a Service Class Provider (SCP), a Service Class User (SCU) or both.

acse_timeout

The maximum amount of time (in seconds) to wait for association related messages. A value of None means no timeout. (default: 30)

Type

int or float or None

active_associations

The currently active associations between the local and peer AEs.

Type

list of association.Association

address

The local AE’s TCP/IP address.

Type

str

ae_title

The local AE’s AE title.

Type

bytes

bind_addr

The network interface to listen to (default: all available network interfaces on the machine).

Type

str

client_socket

The socket used for connections with peer AEs

Type

socket.socket

dimse_timeout

The maximum amount of time (in seconds) to wait for DIMSE related messages. A value of None means no timeout. (default: None)

Type

int or float or None

network_timeout

The maximum amount of time (in seconds) to wait for network messages. A value of None means no timeout. (default: 60)

Type

int or float or None

maximum_associations

The maximum number of simultaneous associations (default: 2)

Type

int

maximum_pdu_size

The maximum PDU receive size in bytes. A value of 0 means there is no maximum size (default: 16382)

Type

int

port

The local AE’s listen port number when acting as an SCP or connection port when acting as an SCU. A value of 0 indicates that the operating system should choose the port.

Type

int

require_calling_aet

If not an empty list, the association request’s Calling AE Title value must match one of the values in require_calling_aet. If an empty list then no matching will be performed (default). (SCP only).

Type

list of bytes

require_called_aet

If True, the association request’s Called AE Title value must match AE.ae_title (default False). (SCP only).

Type

bool

Examples

SCP

To use AE as an SCP, you need to specify:

  • The listen port number that SCUs can use to send Association requests and DIMSE messages

  • The Presentation Contexts that the SCP supports.

If the SCP is being used for any DICOM Service Classes other than the Verification Service Class you also need to implement one or more of the callbacks corresponding to the DIMSE-C services (on_c_store, on_c_find, on_c_get, on_c_move).

The SCP can then be started using ApplicationEntity.start()

C-STORE SCP Example

from pynetdicom import AE, StoragePresentationContexts

# Create the AE and specify the listen port
ae = AE(port=11112)

# Set the supported Presentation Contexts
ae.supported_contexts = StoragePresentationContexts

# Define the callback for receiving a C-STORE request
def on_c_store(dataset, context, info):
    # Insert your C-STORE handling code here

    # Must return a valid C-STORE status - 0x0000 is Success
    return 0x0000

ae.on_c_store = on_c_store

# Start the SCP
ae.start()

SCU

To use AE as an SCU you only need to specify the Presentation Contexts that the SCU is requesting for support by the SCP. You can then call ApplicationEntity.associate(addr, port) where addr and port are the TCP/IP address and the listen port number of the peer SCP, respectively.

Once the Association is established you can then request the use of the peer’s DIMSE-C services.

C-ECHO SCU Example

from pynetdicom import AE, VerificationPresentationContexts

# Create the AE with an AE Title 'MYAE'
ae = AE(ae_title=b'MYAE')

# Specify which SOP Classes are supported as an SCU
ae.requested_contexts = VerificationPresentationContexts

# Request an association with a peer SCP
assoc = ae.associate('192.168.2.1', 104)

if assoc.is_established:
    # Send a C-ECHO request to the peer
    status = assoc.send_c_echo()

    # Release the association
    assoc.release()
__init__(ae_title=b'PYNETDICOM', port=0)[source][source]

Create a new Application Entity.

Parameters
  • ae_title (bytes, optional) – The AE title of the Application Entity (default: b'PYNETDICOM')

  • port (int, optional) – The port number to listen for association requests when acting as an SCP and to use when requesting an association as an SCU. When set to 0 the OS will use the first available port (default 0).

Methods

__init__([ae_title, port])

Create a new Application Entity.

add_requested_context(abstract_syntax[, ...])

Add a Presentation Context to be proposed when sending Association requests.

add_supported_context(abstract_syntax[, ...])

Add a supported presentation context.

associate(addr, port[, contexts, ae_title, ...])

Send an association request to a remote AE.

cleanup_associations()

Remove dead associations.

on_association_aborted([primitive])

Callback for when an association is aborted.

on_association_accepted(primitive)

Callback for when an association is accepted.

on_association_rejected(primitive)

Callback for when an association is rejected.

on_association_released([primitive])

Callback for when an association is released.

on_association_requested(primitive)

Callback for an association is requested.

on_async_ops_window(nr_invoked, nr_performed)

Callback for when an Asynchronous Operations Window Negotiation item is include in the association request.

on_c_echo(context, info)

Callback for when a C-ECHO request is received.

on_c_find(dataset, context, info)

Callback for when a C-FIND request is received.

on_c_find_cancel()

Callback for when a C-FIND-CANCEL request is received.

on_c_get(dataset, context, info)

Callback for when a C-GET request is received.

on_c_get_cancel()

Callback for when a C-GET-CANCEL request is received.

on_c_move(dataset, move_aet, context, info)

Callback for when a C-MOVE request is received.

on_c_move_cancel()

Callback for when a C-MOVE-CANCEL request is received.

on_c_store(dataset, context, info)

Callback for when a C-STORE request is received.

on_make_connection()

Callback for a connection is made.

on_n_action(dataset, context, info)

Callback for when a N-ACTION is received.

on_n_create(dataset, context, info)

Callback for when a N-CREATE is received.

on_n_delete(context, info)

Callback for when a N-DELETE is received.

on_n_event_report(dataset, context, info)

Callback for when a N-EVENT-REPORT is received.

on_n_get(attr, context, info)

Callback for when an N-GET request is received.

on_n_set(dataset, context, info)

Callback for when a N-SET is received.

on_receive_connection()

Callback for a connection is received.

on_sop_class_common_extended(items)

Callback for when one or more SOP Class Common Extended Negotiation items are included in the association request.

on_sop_class_extended(app_info)

Callback for when one or more SOP Class Extended Negotiation items are included in the association request.

on_user_identity(user_id_type, ...)

Callback for when a user identity negotiation item is included with the association request.

quit()

Stop the SCP.

remove_requested_context(abstract_syntax[, ...])

Remove a requested Presentation Context.

remove_supported_context(abstract_syntax[, ...])

Remove a supported presentation context.

start([select_timeout])

Start the AE as an SCP.

stop()

Stop the SCP.

Attributes

acse_timeout

Return the ACSE timeout value.

ae_title

Get the AE title.

dimse_timeout

Get the DIMSE timeout.

implementation_class_uid

Return the current Implementation Class UID.

implementation_version_name

Return the current Implementation Version Name.

maximum_associations

Return the number of maximum associations as int.

maximum_pdu_size

Return the maximum PDU size accepted by the AE as int.

network_timeout

Get the network timeout.

port

Return the port number as an int.

requested_contexts

Return a list of the requested PresentationContext items.

require_called_aet

Return whether the Called AE Title must match ae_title.

require_calling_aet

Return the required calling AE title as a list of bytes.

supported_contexts

Return a list of the supported PresentationContexts items.