Exemplo n.º 1
0
 def time_create_double_transfer_syntax(self):
     """Time creating context with two transfer syntaxes."""
     for x in range(500):
         cx = PresentationContext()
         cx.context_id = 1
         cx.abstract_syntax = '1.2.840.10008.5.1.4.1.1.2'
         cx.transfer_syntax = ['1.2.840.10008.1.2', '1.2.840.10008.1.2.1']
Exemplo n.º 2
0
def send_c_store(ae: AE, dcm_path: str, scp_address: Tuple[str, int],
                 idx: int) -> None:
    host, port = scp_address
    logger.debug(
        f"Establishing an association with DIMSE C-STORE SCP ({host}, {port})")

    dataset = read_file(dcm_path)
    abstract_syntax = dataset.file_meta[0x00020002].value
    transfer_syntax = dataset.file_meta[0x00020010].value

    context = PresentationContext()
    context.abstract_syntax = abstract_syntax
    context.transfer_syntax = [transfer_syntax]

    assoc = ae.associate(host, port, contexts=[context])
    if not assoc.is_established:
        logger.error("Failed to associate with SCP. Exiting...")
        assoc.release()
        return

    try:
        response = assoc.send_c_store(dataset)
        status = response[0x00000900].value
        dcm_file_name = os.path.basename(dcm_path)
        association_syntax = f"{abstract_syntax}{transfer_syntax}"
        logger.info(
            f"({idx}) Sent C-STORE '{dcm_file_name}' - syntax={association_syntax} - status={status}"
        )
    finally:
        assoc.release()
Exemplo n.º 3
0
 def time_create_single_transfer_syntax(self):
     """Time creating contexts with a single transfer syntax"""
     for x in range(500):
         cx = PresentationContext()
         cx.context_id = 1
         cx.abstract_syntax = '1.2.840.10008.5.1.4.1.1.2'
         cx.transfer_syntax = ['1.2.840.10008.1.2']
Exemplo n.º 4
0
 def setup(self):
     self.contexts = []
     for x in range(500):
         cx = PresentationContext()
         cx.context_id = 1
         cx.abstract_syntax = '1.2.840.10008.5.1.4.1.1.2'
         cx.transfer_syntax = [
             '1.2.840.10008.1.2', '1.2.840.10008.1.2.1',
             '1.2.840.10008.1.2.2'
         ]
         self.contexts.append(cx)
Exemplo n.º 5
0
 def time_create_triple_transfer_syntax(self):
     """Time creating context with three transfer syntaxes."""
     for x in range(500):
         cx = PresentationContext()
         cx.context_id = 1
         cx.abstract_syntax = "1.2.840.10008.5.1.4.1.1.2"
         cx.transfer_syntax = [
             "1.2.840.10008.1.2",
             "1.2.840.10008.1.2.1",
             "1.2.840.10008.1.2.2",
         ]
Exemplo n.º 6
0
 def time_create_from_sop(self):
     """Test the time taken to create a PresentationContext from every
     available standard DICOM UID.
     """
     for uid in UID_dictionary:
         cx = PresentationContext()
         cx.context_id = 1
         cx.abstract_syntax = uid
         cx.transfer_syntax = [
             '1.2.840.10008.1.2', '1.2.840.10008.1.2.1',
             '1.2.840.10008.1.2.2'
         ]
Exemplo n.º 7
0
    def setup(self):
        # Requestor presentation contexts - max 128
        self.requestor_contexts = []

        for ii, cx in enumerate(StoragePresentationContexts):
            cx.context_id = ii * 2 + 1
            self.requestor_contexts.append(cx)

        # Acceptor presentation contexts - no max
        self.acceptor_contexts = []

        for uid in UID_dictionary:
            cx = PresentationContext()
            cx.abstract_syntax = uid
            cx.transfer_syntax = [
                '1.2.840.10008.1.2', '1.2.840.10008.1.2.1',
                '1.2.840.10008.1.2.2'
            ]
            self.acceptor_contexts.append(cx)
Exemplo n.º 8
0
    def setup(self):
        # Requestor presentation contexts - max 126
        self.requestor_contexts = []
        for ii, cx in enumerate(StoragePresentationContexts):
            cx.context_id = ii * 2 + 1
            cx.SCP = True
            cx.SCU = True
            self.requestor_contexts.append(cx)

        # Acceptor presentation contexts - no max
        self.acceptor_contexts = []
        for uid in UID_dictionary:
            context = PresentationContext()
            context.context_id = 1
            context.abstract_syntax = uid
            context.transfer_syntax = ['1.2.840.10008.1.2']
            context.Result = 0x00
            context.SCP = True
            context.SCU = True
            self.acceptor_contexts.append(context)
Exemplo n.º 9
0
    def test_conversion(self):
        """ Check conversion to a PDU produces the correct output """
        assoc = A_ASSOCIATE()
        assoc.application_context_name = "1.2.840.10008.3.1.1.1"
        assoc.calling_ae_title = 'ECHOSCU'
        assoc.called_ae_title = 'ANY-SCP'
        assoc.maximum_length_received = 16382
        assoc.implementation_class_uid = '1.2.826.0.1.3680043.9.3811.0.9.0'

        imp_ver_name = ImplementationVersionNameNotification()
        imp_ver_name.implementation_version_name = 'PYNETDICOM_090'
        assoc.user_information.append(imp_ver_name)

        pc = PresentationContext()
        pc.context_id = 1
        pc.abstract_syntax = '1.2.840.10008.1.1'
        pc.transfer_syntax = ['1.2.840.10008.1.2']
        assoc.presentation_context_definition_list = [pc]

        pdu = A_ASSOCIATE_RQ()
        pdu.from_primitive(assoc)
        data = pdu.encode()

        assert data == (
            b"\x01\x00\x00\x00\x00\xd1\x00\x01\x00\x00\x41\x4e\x59\x2d\x53\x43"
            b"\x50\x20\x20\x20\x20\x20\x20\x20\x20\x20\x45\x43\x48\x4f\x53\x43"
            b"\x55\x20\x20\x20\x20\x20\x20\x20\x20\x20\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x15\x31\x2e"
            b"\x32\x2e\x38\x34\x30\x2e\x31\x30\x30\x30\x38\x2e\x33\x2e\x31\x2e"
            b"\x31\x2e\x31\x20\x00\x00\x2e\x01\x00\x00\x00\x30\x00\x00\x11\x31"
            b"\x2e\x32\x2e\x38\x34\x30\x2e\x31\x30\x30\x30\x38\x2e\x31\x2e\x31"
            b"\x40\x00\x00\x11\x31\x2e\x32\x2e\x38\x34\x30\x2e\x31\x30\x30\x30"
            b"\x38\x2e\x31\x2e\x32\x50\x00\x00\x3e\x51\x00\x00\x04\x00\x00\x3f"
            b"\xfe\x52\x00\x00\x20\x31\x2e\x32\x2e\x38\x32\x36\x2e\x30\x2e\x31"
            b"\x2e\x33\x36\x38\x30\x30\x34\x33\x2e\x39\x2e\x33\x38\x31\x31\x2e"
            b"\x30\x2e\x39\x2e\x30\x55\x00\x00\x0e\x50\x59\x4e\x45\x54\x44\x49"
            b"\x43\x4f\x4d\x5f\x30\x39\x30"
        )
Exemplo n.º 10
0
    def setup(self):
        # Requestor presentation contexts - max 126
        self.requestor_contexts = []
        for ii, cx in enumerate(StoragePresentationContexts):
            cx.context_id = ii * 2 + 1
            cx.scp_role = True
            cx.scu_role = True
            self.requestor_contexts.append(cx)

        # Acceptor presentation contexts - no max
        self.acceptor_contexts = []
        for uid in UID_dictionary:
            cx = PresentationContext()
            cx.abstract_syntax = uid
            cx.transfer_syntax = [
                "1.2.840.10008.1.2",
                "1.2.840.10008.1.2.1",
                "1.2.840.10008.1.2.2",
            ]
            self.acceptor_contexts.append(cx)

        self.ac_roles = {uid: (True, False) for uid in UID_dictionary}
Exemplo n.º 11
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from pynetdicom.presentation import PresentationContext
from pynetdicom import build_context

cx = PresentationContext()
cx.context_id = 1
# 1.2.840.10008.1.1 - Verification SOP Class
# 1.2.840.10008.5.1.4.1.1 - CT Image Storage
cx.abstract_syntax = '1.2.840.10008.1.1'
# 1.2.840.10008.1.2 - Implicit VR Little Endian
# 1.2.840.10008.1.2.4.50 - JPEG Baseline
cx.transfer_syntax = ['1.2.840.10008.1.2', '1.2.840.10008.1.2.4.50']
print(cx)

cx1 = build_context(
    '1.2.840.10008.1.1', ['1.2.840.10008.5.1.4.1.1.3.1']
)
print(cx1)
cx2 = build_context('1.2.840.10008.1.1')
print(cx2)