pynetdicom.dimse.DIMSEServiceProvider

class pynetdicom.dimse.DIMSEServiceProvider(assoc: Association)[source]

The DIMSE service provider.

Changed in version 1.2: Added msg_queue attribute

Messages

Primitive

Type

Message Class

C-CANCEL

Request/indication

C_CANCEL_RQ

C-ECHO

Request/indication

C_ECHO_RQ

Response/confirmation

C_ECHO_RSP

C-FIND

Request/indication

C_FIND_RQ

Response/confirmation

C_FIND_RSP

C-GET

Request/indication

C_GET_RQ

Response/confirmation

C_GET_RSP

C-MOVE

Request/indication

C_MOVE_RQ

Response/confirmation

C_MOVE_RSP

C-STORE

Request/indication

C_STORE_RQ

Response/confirmation

C_STORE_RSP

N-ACTION

Request/indication

N_ACTION_RQ

Response/confirmation

N_ACTION_RSP

N-CREATE

Request/indication

N_CREATE_RQ

Response/confirmation

N_CREATE_RSP

N-DELETE

Request/indication

N_DELETE_RQ

Response/confirmation

N_DELETE_RSP

N-EVENT-REPORT

Request/indication

N_EVENT_REPORT_RQ

Response/confirmation

N_EVENT_REPORT_RSP

N-GET

Request/indication

N_GET_RQ

Response/confirmation

N_GET_RSP

N-SET

Request/indication

N_SET_RQ

Response/confirmation

N_SET_RSP

cancel_rq

A dict of {MessageIDBeingRespondedTo : C_CANCEL} messages received. The dict is cleared out at the start and end of Service Class operations and is limited to a maximum of 10 messages.

Type:

dict

message

The DIMSE message currently being received.

Type:

dimse_messages.DIMSEMessage or None

msg_queue

A queue holding decoded DIMSE Message primitives received from the peer, except for C-CANCEL requests.

Type:

queue.queue of dimse_messages.DIMSEMessage

References

__init__(assoc: Association) None[source]

Initialise the DIMSE service provider.

Changed in version 1.3: Class initialisation now only takes assoc parameter.

Parameters:

assoc (association.Association) – The association to provide DIMSE services for.

Methods

__init__(assoc)

Initialise the DIMSE service provider.

get_msg([block])

Get the next available DIMSE message.

peek_msg()

Return the first message in the message queue or None.

receive_primitive(primitive)

Process a P-DATA primitive received from the remote.

send_msg(primitive, context_id)

Encode and send a DIMSE-C or DIMSE-N message to the peer AE.

Attributes

assoc

Return the parent Association.

dimse_timeout

Return the DIMSE timeout as numeric or None.

dul

Return the DULServiceProvider.

maximum_pdu_size

Return the peer's maximum PDU length as int.

property assoc: Association

Return the parent Association.

Added in version 1.3.

property dimse_timeout: float | None

Return the DIMSE timeout as numeric or None.

property dul: DULServiceProvider

Return the DULServiceProvider.

get_msg(block: bool = False) Tuple[None, None] | Tuple[int, C_ECHO | C_FIND | C_GET | C_MOVE | C_STORE | N_ACTION | N_CREATE | N_DELETE | N_EVENT_REPORT | N_GET | N_SET][source]

Get the next available DIMSE message.

Added in version 1.2.

Changed in version 1.5: Changed to also return (None, None) if the peer aborts the association or the connection is closed.

Parameters:

block (bool) – If True then the function will block until either a message is available or dimse_timeout expires, otherwise non-blocking.

Returns:

The next available (Context ID, DIMSE Message), which is taken off the queue, or (None, None) if the peer has aborted the association, the connection is closed or if no messages are available within the dimse_timeout period.

Return type:

(int, dimse_messages.DIMSEMessage) or (None, None)

property maximum_pdu_size: int

Return the peer’s maximum PDU length as int.

peek_msg() Tuple[None, None] | Tuple[int, C_ECHO | C_FIND | C_GET | C_MOVE | C_STORE | N_ACTION | N_CREATE | N_DELETE | N_EVENT_REPORT | N_GET | N_SET][source]

Return the first message in the message queue or None.

Added in version 1.2.

Returns:

The first (Context ID, Message) in the queue if one is available, otherwise (None, None). No messages are taken out of the queue.

Return type:

(int, dimse_messages.DIMSEMessage) or (None, None)

receive_primitive(primitive: P_DATA) None[source]

Process a P-DATA primitive received from the remote.

Added in version 1.2.

A DIMSE message is split into one or more P-DATA primitives, which must be sent in sequential order. While waiting for all the P-DATA primitives associated with a message the encoded data is stored in message, which is decoded only when complete and converted into a DIMSE Message primitive which is added to the msg_queue.

This makes it possible to process incoming P-DATA primitives into DIMSE messages while a service class implementation is running.

Parameters:

primitive (pdu_primitives.P_DATA) – A P-DATA primitive received from the peer to be processed.

send_msg(primitive: C_CANCEL | C_ECHO | C_FIND | C_GET | C_MOVE | C_STORE | N_ACTION | N_CREATE | N_DELETE | N_EVENT_REPORT | N_GET | N_SET, context_id: int) None[source]

Encode and send a DIMSE-C or DIMSE-N message to the peer AE.

Parameters:
  • primitive (dimse_primitives DIMSE Primitive class) – The DIMSE message primitive to send to the peer.

  • context_id (int) – The ID of the presentation context that the message is to be sent under.