-
Notifications
You must be signed in to change notification settings - Fork 13
/
scp.py
37 lines (27 loc) · 1.2 KB
/
scp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from pydicom.dataset import FileMetaDataset
from pynetdicom import AE, events, evt, debug_logger
from pynetdicom.sop_class import MRImageStorage
debug_logger()
class ModalityStoreSCP():
def __init__(self) -> None:
self.ae = AE(ae_title=b'STORESCP')
self.scp = None
self._configure_ae()
def _configure_ae(self) -> None:
"""Configure the Application Entity with the presentation context(s) which should be supported and start the SCP server.
"""
handlers = [(evt.EVT_C_STORE, self.handle_store)]
self.ae.add_supported_context(MRImageStorage)
self.scp = self.ae.start_server(('127.0.0.1', 6667), block=False, evt_handlers=handlers)
print("SCP Server started")
def handle_store(self, event: events.Event) -> int:
"""Callable handler function used to handle a C-STORE event.
Args:
event (Event): Representation of a C-STORE event.
Returns:
int: Status Code
"""
dataset = event.dataset
dataset.file_meta = FileMetaDataset(event.file_meta)
# TODO: Do something with the dataset. Think about how you can transfer the dataset from this place
return 0x0000