Association (asceprovider)¶
Module contains two key classes for working with DICOM associations:
AssociationAcceptorfor handling incoming association requests.
AssociationRequesterfor requesting association.
In most cases you won’t have to create AssociationAcceptor or
AssociationRequester directly, but rather they will be created for you by
either ClientAE or
AE. Please, refer to documentation
on those classes on how to request new association or how incoming association
are handled.
Each association class is not only responsible for initial establishment, but also for all association life-cycle until it’s either released or aborted.
- class pynetdicom2.asceprovider.RemoteAEConfig(aet: str, address: str, port: int, username: str | None = None, password: str | None = None, kerberos: None | str | bytes = None, saml: None | str | bytes = None, jwt: None | str | bytes = None, user_data: list[ImplementationClassUIDSubItem | MaximumLengthSubItem | ImplementationVersionNameSubItem | AsynchronousOperationsWindowSubItem | ScpScuRoleSelectionSubItem | SOPClassExtendedNegotiationSubItem | UserIdentityNegotiationSubItem | UserIdentityNegotiationSubItemAc | GenericUserDataSubItem] = <factory>)¶
Connection settings for establishing remote association
- kerberos: None | str | bytes = None¶
Kerberos, SAML and JWT credentials may be opaque binary data, so both
strandbytesare accepted.
- class pynetdicom2.asceprovider.AETParams(address: str, aet: str, port: int | None = None)¶
AE Title parameters such as address, AE title itself and port
- class pynetdicom2.asceprovider.PContextDefList(id: int, sop_class: UID, supported_ts: frozenset[UID])¶
Presentation Context Definition list item
- class pynetdicom2.asceprovider.SCPServiceWithSOPClass(*args, **kwargs)¶
Service Content Provider Protocol augmented with supported SOP Class UIDs.
- class pynetdicom2.asceprovider.SCPService(*args, **kwargs)¶
Service Content Provider Protocol.
- class pynetdicom2.asceprovider.SCUService(*args, **kwargs)¶
Service Content User protocol.
- class pynetdicom2.asceprovider.SCUServiceWithSOPClass(*args, **kwargs)¶
Service Content User protocol augmented with supported SOP Class UIDs.
- class pynetdicom2.asceprovider.AEBaseProto(*args, **kwargs)¶
Application Entity Protocol. Main implementation are in another module :module:`~pynetdicom2.applicationentity`
- add_scu(service: SCUServiceWithSOPClass, sop_classes: list[UID] | None = None) AEBaseProto¶
Adds service as SCU to the AE.
- update_context_def_list(sop_classes: Iterable[UID], store_in_file: bool = False) None¶
Updates presentation context definition list.
- copy_context_def_list() dict[int, PContextDefList]¶
Makes a shallow copy of presentation context definition list.
- get_file(context: PContextDef, command_set: Dataset) tuple[BinaryIO, int]¶
Method is used by association to get file-like object to store dataset.
- request_association(remote_ae: RemoteAEConfig | dict[str, Any]) Iterator[AssociationRequester]¶
Requests association to a remote application entity.
- on_association_request(asce: AssociationAcceptor, assoc: AAssociateRqPDU) None¶
Extra processing of an association request.
- on_association_response(response: AAssociateAcPDU) None¶
Extra processing for an association response.
- on_abort(asce: Association, exc: AssociationAbortedError) None¶
Called to handle
AssociationAbortedError
- on_dcm_timeout(asce: Association, exc: DCMTimeoutError) None¶
Called to handle
DCMTimeoutError
- on_receive_echo(context: PContextDef) Status¶
Handling of a C-ECHO command.
- on_receive_store(context: PContextDef, ds: BinaryIO | bytes) Status¶
Handling of a C-STORE command.
- on_receive_find(context: PContextDef, ds: Dataset) Iterator[tuple[Dataset, Status]]¶
Handling of a C-FIND command.
- on_receive_move(context: PContextDef, ds: Dataset, destination: str) tuple[RemoteAEConfig, int, Iterator[Dataset]]¶
Handling of a C-MOVE command.
- on_commitment_request(remote_ae: str, uids: Iterable[tuple[UID, UID]]) tuple[RemoteAEConfig, Iterable[tuple[UID, UID]], Iterable[tuple[UID, UID, int]]]¶
Handle storage commitment request.
- on_commitment_response(transaction_uid: UID, success: Iterable[tuple[UID, UID]], failure: Iterable[tuple[UID, UID, int]]) None¶
Handle storage commitment response.
- pynetdicom2.asceprovider.UNSUPPORTED_REQUEST_RESPONSES: dict[int, type[DIMSEResponseMessage]] = {1: <class 'pynetdicom2.dimsemessages.CStoreRSPMessage'>, 16: <class 'pynetdicom2.dimsemessages.CGetRSPMessage'>, 32: <class 'pynetdicom2.dimsemessages.CFindRSPMessage'>, 33: <class 'pynetdicom2.dimsemessages.CMoveRSPMessage'>, 48: <class 'pynetdicom2.dimsemessages.CEchoRSPMessage'>, 256: <class 'pynetdicom2.dimsemessages.NEventReportRSPMessage'>, 272: <class 'pynetdicom2.dimsemessages.NGetRSPMessage'>, 288: <class 'pynetdicom2.dimsemessages.NSetRSPMessage'>, 304: <class 'pynetdicom2.dimsemessages.NActionRSPMessage'>, 320: <class 'pynetdicom2.dimsemessages.NCreateRSPMessage'>, 336: <class 'pynetdicom2.dimsemessages.NDeleteRSPMessage'>}¶
Response classes used to refuse a request that was received for an unsupported SOP Class, keyed by the request’s command field. Refusing the individual request keeps the association usable for other requests.
- pynetdicom2.asceprovider.build_pres_context_def_list(context_def_list: dict[int, PContextDefList]) Iterable[PresentationContextItemRQ]¶
Builds a list of Presentation Context Items
- Parameters:
context_def_list – list of tuples (presentation context ID and PContextDef)
- Returns:
generator that yields
pynetdicom2.pdu.PresentationContextItemRQinstances
- class pynetdicom2.asceprovider.Association(local_ae: AEBaseProto, dul_socket: socket | None, max_pdu_length: int)¶
Base association class.
Class is not intended for direct usage and meant to be sub-classed. Class provides basic association interface: creation, release and abort.
- send(dimse_msg: DIMSEMessage, pc_id: int) None¶
Sends DIMSE message
- Parameters:
dimse_msg – DIMSE message
pc_id – Presentation Context Definition
- receive() tuple[DIMSEMessage, int]¶
Receives DIMSE message
- Returns:
tuple, containing DIMSE message and presentation context ID
- kill() None¶
Stops internal DUL service provider.
In most cases you won’t need to use this method directly. Refer to release and abort instead.
- release() AReleaseRpPDU¶
Releases association.
Requests the release of the association and waits for confirmation. If the remote AE requested release at the same time (release collision, PS3.7 7.2.4) its request is approved as well.
- class pynetdicom2.asceprovider.AssociationAcceptor(request: socket, local_ae: AEBaseProto, max_pdu_length: int)¶
‘Server-side’ association implementation.
Class is intended for handling incoming association requests.
- kill() None¶
Overrides base class kill method to set stop-flag for running thread
- abort(reason: int) None¶
Aborts association with specified reason
- Parameters:
reason – abort reason
- reject(result: int, source: int, diag: int) None¶
Rejects association with specified parameters
- Parameters:
result
source
diag
- accept(assoc_req: AAssociateRqPDU) None¶
Waits for an association request from a remote AE. Upon reception of the request sends association response based on acceptable_pr_contexts
- handle() None¶
Handles the incoming connection to accepting or rejecting the association and then handling incoming commands.
- class pynetdicom2.asceprovider.AssociationRequester(local_ae: AEBaseProto, max_pdu_length: int, remote_ae: RemoteAEConfig | dict[str, Any])¶
Class for managing association request.
Generally you would not need to construct this class directly, rather it would be created for you, when using
AEorClientAE.- Variables:
context_def_list – presentation context definitions in a form of dict (PC ID -> Presentation Context)
remote_ae – dictionary, containing remote AET, address, port and other information
sop_classes_as_scu – dictionary which maps accepted SOP Classes to presentation contexts. empty, until association is established.
- request() None¶
Requests association with remote AET.
- get_scu(sop_class: UID) Callable[[...], Any]¶
Get SCU function to use (like for making a C-FIND request).
SCU are generally provided by sopclass module. First argument of the service would be bound to current association and second would be bound to current presentation context.
- Parameters:
sop_class – SOP Class UID
- Raises:
exceptions.ClassNotSupportedError – raised if provided SOP Class UID is not supported by association.
- Returns:
SCU function
- abort(reason: int = 0) None¶
Aborts association with specified reason
- Parameters:
reason – abort reason