Exemplo n.º 1
0
 def test_max_pdu_good(self):
     """ Check AE maximum pdu size change produces good value """
     ae = AE(scu_sop_class=['1.2.840.10008.1.1'])
     ae.maximum_pdu_size = -10
     self.assertTrue(ae.maximum_pdu_size == 16382)
     ae.maximum_pdu_size = 0
     self.assertTrue(ae.maximum_pdu_size == 0)
     ae.maximum_pdu_size = 5000
     self.assertTrue(ae.maximum_pdu_size == 5000)
Exemplo n.º 2
0
    def __init__(self,
                 dicom_home,
                 port=11112,
                 name="FINDSCP",
                 prefer_uncompr=True,
                 prefer_little=False,
                 prefer_big=False,
                 implicit=False,
                 timeout=None,
                 dimse_timeout=None,
                 acse_timeout=60,
                 pdu_max=16384,
                 update_on_find=False,
                 start=False):
        '''create a FindSCP (Service Class Provider) for query/retrieve and basic workflow management
        :param dicom_home: must be the base folder of dicom files **TODO: make this more robust
        :param port: TCP/IP port number to listen on
        :param name: the title/name for the ae. 'FINDSCP' is used if not defined.
        :param prefer_uncompr: prefer explicit VR local byte order (default)
        :param prefer_little: prefer explicit VR little endian TS
        :param perfer_big: prefer explicit VR big endian TS
        :param implicit: accept implicit VR little endian TS only
        :param timeout: timeout for connection requests (default None)
        :param acse_timeout: timeout for ACSE messages (default 60)
        :param dimse_timeout: timeout for the DIMSE messages (default None) 
        :param pdu_max: set max receive pdu to n bytes (4096..131072) default 16382
        :param update_on_find: if True, dicoms in dicom_home are updated on the find request
        '''
        self.port = port

        # Base for dicom files (we can do better here)
        self.base = dicom_home

        self.dicoms = get_dicom_files(self.base)
        self.update_on_find = update_on_find

        # Update preferences
        self.update_transfer_syntax(prefer_uncompr=prefer_uncompr,
                                    prefer_little=prefer_little,
                                    prefer_big=prefer_big,
                                    implicit=implicit)

        ae = AE(scp_sop_class=QueryRetrieveSOPClassList,
                transfer_syntax=self.transfer_syntax,
                scu_sop_class=[],
                ae_title=name,
                port=self.port)

        # Set timeouts, name, transfer
        ae.maximum_pdu_size = pdu_max
        ae.network_timeout = timeout
        ae.acse_timeout = acse_timeout
        ae.dimse_timeout = dimse_timeout

        BaseSCP.__init__(self, ae=ae)
        self.status = self.pending_matches
        self.cancel = False

        if start is True:
            self.run()
Exemplo n.º 3
0
    def __init__(self, port=11112, peer=None, to_port=None, 
                       to_name="ANY-SCP", name='STORESCU', prefer_uncompr=True,
                       prefer_little=False, repeat=1, prefer_big=False, 
                       implicit=False, timeout=None, dimse_timeout=None,
                       acse_timeout=60, pdu_max=16382, start=False):

        '''
        :param port: the port to use, default is 11112.
        :param peer: the hostname of DICOM peer (not required)
        :param toport: the port of the peer to send to
        :parm toname: the name of the peer to send to
        :param repeat: repeat N times (default is 1)
        :param name: the title/name for the ae. 'ECHOSCU' is used if not defined.
        :param prefer_uncompr: prefer explicit VR local byte order (default)
        :param prefer_little: prefer explicit VR little endian TS
        :param perfer_big: prefer explicit VR big endian TS
        :param implicit: accept implicit VR little endian TS only
        :param timeout: timeout for connection requests (default None)
        :param acse_timeout: timeout for ACSE messages (default 60)
        :param dimse_timeout: timeout for the DIMSE messages (default None) 
        :param pdu_max: set max receive pdu to n bytes (4096..131072) default 16382
        :param start: if True, start the ae. (default False)
        :param abort: if True, abort the association after releasing it (default False)
        ''' 
        self.port = port
        self.repeat = repeat
        self.abort = abort
        self.update_peer(peer=peer,
                         port=to_port,
                         name=to_name)
     
        # Update preferences
        self.update_transfer_syntax(prefer_uncompr=prefer_uncompr,
                                    prefer_little=prefer_little,
                                    prefer_big=prefer_big,
                                    implicit=implicit)

        ae = AE(ae_title=name,
                port=self.port,
                scu_sop_class=StorageSOPClassList,
                scp_sop_class=[],
                transfer_syntax=self.transfer_syntax)


        # Set timeouts, name, transfer
        ae.ae_title=name
        ae.maximum_pdu_size = pdu_max
        ae.network_timeout = timeout
        ae.acse_timeout = acse_timeout
        ae.dimse_timeout = dimse_timeout
        BaseSCU.__init__(self,ae=ae)
        self.status = self.success
Exemplo n.º 4
0
    def __init__(self,
                 port=11112,
                 name="ECHOSCP",
                 prefer_uncompr=True,
                 prefer_little=False,
                 prefer_big=False,
                 implicit=False,
                 timeout=None,
                 dimse_timeout=None,
                 acse_timeout=60,
                 pdu_max=16384,
                 start=False):
        '''
        :param port: the port to use, default is 11112.
        :param name: the title/name for the ae. 'ECHOSCP' is used if not defined.
        :param prefer_uncompr: prefer explicit VR local byte order (default)
        :param prefer_little: prefer explicit VR little endian TS
        :param perfer_big: prefer explicit VR big endian TS
        :param implicit: accept implicit VR little endian TS only
        :param timeout: timeout for connection requests (default None)
        :param acse_timeout: timeout for ACSE messages (default 60)
        :param dimse_timeout: timeout for the DIMSE messages (default None) 
        :param pdu_max: set max receive pdu to n bytes (4096..131072) default 16382
        :param start: if True, start the ae.
        '''
        self.port = port

        # Update preferences
        self.update_transfer_syntax(prefer_uncompr=prefer_uncompr,
                                    prefer_little=prefer_little,
                                    prefer_big=prefer_big,
                                    implicit=implicit)

        ae = AE(scp_sop_class=[VerificationSOPClass],
                scu_sop_class=[],
                port=self.port,
                transfer_syntax=self.transfer_syntax)

        # Set timeouts, name, transfer
        ae.ae_title = name
        ae.maximum_pdu_size = pdu_max
        ae.network_timeout = timeout
        ae.acse_timeout = acse_timeout
        ae.dimse_timeout = dimse_timeout
        BaseSCP.__init__(self, ae=ae)

        if start is True:
            self.run()
Exemplo n.º 5
0
        data = dcmread(dcm, force=True)

        ds = Dataset()
        if 'QueryRetrieveLevel' in dataset:
            ds.QueryRetrieveLevel = dataset.QueryRetrieveLevel
        ds.RetrieveAETitle = args.aetitle
        ds.PatientName = data.PatientName

        status_ds = Dataset()
        status_ds.Status = 0xFF00
        yield status_ds, ds


# Create application entity
ae = AE(ae_title=args.aetitle,
        port=args.port,
        scu_sop_class=[],
        scp_sop_class=QueryRetrieveSOPClassList,
        transfer_syntax=transfer_syntax)

ae.maximum_pdu_size = args.max_pdu

# Set timeouts
ae.network_timeout = args.timeout
ae.acse_timeout = args.acse_timeout
ae.dimse_timeout = args.dimse_timeout

ae.on_c_find = on_c_find

ae.start()