DUL Service Provider (dulprovider)¶
This module implements the DUL service provider, allowing a DUL service user to send and receive DUL messages (PDUs). The User and Provider talk to each other using a TCP socket. The DULServer runs in a thread, polling TCP socket for incoming messages and sending messages from user queue. Underlying logic of the service is implemented via state machine that is described in DICOM standard.
In most of the cases you would not need to access
DULServiceProvider
directly, but rather would
use higher level objects like sub-classes of
Association
or various services.
-
class
pynetdicom2.dulprovider.
DULServiceProvider
(store_in_file, get_file_cb, dul_socket=None, max_pdu_length=65536)¶ Implements DUL service.
This class is responsible for low-level operations with incoming and outgoing PDUs.
Service can be initialized by providing open socket that service would use for sending and receiving PDUs. In case if socket is not provider service opens a client socket by itself when sending
AAssociateRqPDU
instance.Underlying implementation relies on state machine that is defined in Service State Machine (fsm)
Variables: - primitive – current PDU
- dimse_gen – generator, used break current outgoing DIMSE message into P-DATA-TF PDUs
- event – current event
- max_pdu_length – maximum PDU length for incoming P-DATA-TF PDUs
- to_service_user – outgoing data queue
- from_service_user – incoming data queue
- dul_socket – socket, that service uses
- is_killed – DUL service termination flag
-
accepted_contexts
¶ Accepted presentation contexts in the current association
-
send
(primitive)¶ Puts PDU into outgoing queue.
Note
PDU is not immediately written into the socket, but rather put into queue that is processed by the service event loop.
Parameters: primitive – outgoing PDU. Possible PDU types are described in PDU Types (pdu)
-
receive
(timeout)¶ Tries to get PDU from incoming queue.
If timeout is exceeded method rises
DCMTimeoutError
exception.Parameters: timeout – the amount of seconds method waits for PDU to appear in incoming queue Returns: PDU instance or a tuple containing DIMSE Message and Presentation Context ID. Possible PDU types are described in PDU Types (pdu). Possible DIMSE messages are described in DIMSE Messages (dimsemessages). Raises: exceptions.DCMTimeoutError – If specified timeout is exceeded
-
stop
()¶ Tries to stop service for idle association.
If association is not in idle state, method will return
False
and association will not be stopped.Returns: True
if service termination flag was successfully set (current association state was ‘idle’),False
otherwise
-
kill
()¶ Sets termination flag for event loop and waits for thread to exit.
-
run
()¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.