Events¶
pynetdicom uses an event-handler system to give the user access to the
data exchanged between different services within an AE as well as the PDUs
and data sent between the local and peer AEs. Two different types of events
are used: notification events and intervention events. Events are imported
using from pynetdicom import evt.
Notification Events¶
Notification events are those events where bound event handlers don’t need to return or yield anything (i.e. the user is notified some event has occurred). Each notification event can have multiple handlers bound to it and any exceptions raised by the handlers are caught and the exception message logged instead. The table below lists the available notification events.
Event |
Description |
|---|---|
|
Association aborted |
|
Association accepted |
|
ACSE received a primitive from the DUL service provider |
|
ACSE sent a primitive to the DUL service provider |
|
Connection with remote closed |
|
Connection with remote opened |
|
Data received from the peer AE |
|
Data sent to the peer AE |
|
DIMSE service received and decoded a message |
|
DIMSE service encoded and sent a message |
|
Association established |
|
State machine transitioning |
|
PDU received from the peer AE |
|
PDU sent to the peer AE |
|
Association rejected |
|
Association released |
|
Association requested |
Intervention Events¶
Intervention events are those events where the bound event handler must return
or yield certain expected values so that pynetdicom can complete an action
(i.e. user intervention is required).
Each intervention event has only a single handler bound to it at all times.
If the user hasn’t bound their own handler then a default will be
used, which usually returns a negative response (i.e. service request failed,
or extended negotiation ignored). The sole exception is the default handler
for evt.EVT_C_ECHO which returns an 0x0000 Success status. The
table below lists the possible intervention events.
Event |
Description |
|
|---|---|---|
Association request includes extended negotiation items |
||
|
Association request includes Asynchronous Operations Window negotiation item |
|
|
Association request includes SOP Class Common Extended negotiation item(s) |
|
|
Association request includes SOP Class Extended negotiation item(s) |
|
|
Association request includes User Identity negotiation item |
|
Service class received a DIMSE service request |
||
|
Service class received C-ECHO request |
|
|
Service class received C-FIND request |
|
|
Service class received C-GET request |
|
|
Service class received C-MOVE request |
|
|
Service class received C-STORE request |
|
|
Service class received N-GET request |
|
Event Handlers¶
All handlers bound to an event are passed a single parameter event which is
an Event instance. All Event objects
come with at least four attributes:
Event.assoc- theAssociationin which the event occurredEvent.description- a str description of the eventEvent.name- the name of the eventEvent.timestamp- the date and time the event occurred at (as a python datetime).
Additional attributes and properties are available depending on the event type, see the handler implementation documentation for more information.
Handlers can be bound to events through the bind(event, handler) methods
in the Association and AssociationServer classes or by using the
evt_handler keyword parameter to AE.associate() and
AE.start_server(). Handlers can be unbound with the
unbind(event, handler) methods in the Association and
AssociationServer classes. See the Association
guide for more details.