def OnReceiveEcho(self): print print "Echo received" return True def OnReceiveFind(self, ds): for ii in range(1000): ds.PatientsName = 'titi' + str(ii) print "sending fake response: patient name: %s" % ds.PatientsName yield ds, 0xFF00 # responding to find request # create application entity MyAE = AE('localhost', 9999, [], [PatientRootFindSOPClass, VerificationSOPClass]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho MyAE.OnReceiveFind = OnReceiveFind dcmtkscu.run_in_term( 'findscu -v -P -aec AE1 -k 0010,0010="*" -k 0008,0052="PATIENT"' ' localhost 9999') # start application entity MyAE.start() MyAE.QuitOnKeyboardInterrupt()
print ds print yield ds, 0xFF00 # responding to find request # setup AE print 'Create AE...' MyAE = netdicom.AE('localhost', 9999, SOPSCU=[], SOPSCP=[ netdicom.VerificationSOPClass, netdicom.ModalityWorklistInformationFindSOPClass ]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho MyAE.OnReceiveFind = OnReceiveFind # Start modality simulator dcmtkscu.run_in_term( 'findscu -v -W -aec AE1 -k 0010,0020="*" -k 0010,0040="*" -k 0010,0030="*" ' '-k 0008,0052="PATIENT" -k 0008,0060="MR" -k 0040,0001="*" ' 'localhost 9999') # start AE print "starting AE ... " MyAE.start() print "Entering processing loop..." MyAE.QuitOnKeyboardInterrupt()
# ds is the identifyer dataset # pretend that we lookup the database to find a list of datasets to be # moved yield dict(AET=remoteAE, Port=2001, Address='localhost') nop = 10 yield nop for ii in range(nop): # create fake dataset ds = dicom.read_file(os.path.join(testfiles_dir(), "rtplan.dcm")) print "sending fake dataset" yield ds # create application entity MyAE = AE('localhost', 9999, [RTPlanStorageSOPClass], [PatientRootMoveSOPClass, VerificationSOPClass]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho MyAE.OnReceiveMove = OnReceiveMove dcmtkscu.run_in_term( 'movescu -v -P -aem AE1 -k 0010,0010="*" -k 0008,0052="PATIENT" ' 'localhost 9999') # start application entity MyAE.start() MyAE.QuitOnKeyboardInterrupt()
# must return appropriate status return 0 # setup AE MyAE = AE( "SPIN", 9999, [], [ MRImageStorageSOPClass, CTImageStorageSOPClass, RTImageStorageSOPClass, RTPlanStorageSOPClass, VerificationSOPClass, ], ) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnAssociateResponse = OnAssociateResponse MyAE.OnReceiveStore = OnReceiveStore MyAE.OnReceiveEcho = OnReceiveEcho dcmtkscu.run_in_term("storescu -d localhost 9999 " + os.path.join(testfiles_dir(), "rtplan.dcm")) # start AE print "starting AE ...," MyAE.start() print "done" MyAE.QuitOnKeyboardInterrupt()
ds.is_little_endian = True ds.is_implicit_VR = True ds.save_as(filename) print "File %s written" % filename # must return appropriate status return 0 # setup AE MyAE = AE('SPIN', 9999, [],[MRImageStorageSOPClass, CTImageStorageSOPClass, RTImageStorageSOPClass, RTPlanStorageSOPClass, VerificationSOPClass]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnAssociateResponse = OnAssociateResponse MyAE.OnReceiveStore = OnReceiveStore MyAE.OnReceiveEcho = OnReceiveEcho dcmtkscu.run_in_term('storescu -d localhost 9999 ' + os.path.join(testfiles_dir(), 'rtplan.dcm')) # start AE print "starting AE ...," MyAE.start() print "done" MyAE.QuitOnKeyboardInterrupt()
import sys sys.path.append('..') import time import netdicom import dcmtkscu # call backs def OnAssociateRequest(association): print "Association request received" def OnReceiveEcho(self): print "Echo received" return True # create application entity MyAE = netdicom.AE('localhost', 9999, [], [netdicom.VerificationSOPClass]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho dcmtkscu.run_in_term('echoscu -v localhost 9999') # start application entity MyAE.start() MyAE.QuitOnKeyboardInterrupt()
file_meta.ImplementationClassUID = "1.2.3.4" # !!! Need valid UIDs here filename = '/tmp/%s.dcm' % DS.SOPInstanceUID ds = FileDataset(filename, {}, file_meta=file_meta, preamble="\0" * 128) ds.update(DS) ds.is_little_endian = True ds.is_implicit_VR = True ds.save_as(filename) print "File %s written" % filename # must return appropriate status return 0 # setup AE MyAE = AE('SPIN', 9999, [], [ MRImageStorageSOPClass, CTImageStorageSOPClass, RTImageStorageSOPClass, RTPlanStorageSOPClass, VerificationSOPClass ]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnAssociateResponse = OnAssociateResponse MyAE.OnReceiveStore = OnReceiveStore MyAE.OnReceiveEcho = OnReceiveEcho dcmtkscu.run_in_term('storescu -d localhost 9999 ' + os.path.join(testfiles_dir(), 'rtplan.dcm')) # start AE print "starting AE ...," MyAE.start() print "done" MyAE.QuitOnKeyboardInterrupt()
def OnReceiveMove(self, ident, remoteAE): # ds is the identifyer dataset # pretend that we lookup the database to find a list of datasets to be moved yield dict(AET=remoteAE, Port=2001, Address='localhost') nop = 10 yield nop for ii in range(nop): # create fake dataset ds = dicom.read_file(os.path.join(testfiles_dir(), "rtplan.dcm")) print "sending fake dataset" yield ds # create application entity MyAE = AE('localhost', 9999, [RTPlanStorageSOPClass], [PatientRootMoveSOPClass, VerificationSOPClass]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho MyAE.OnReceiveMove = OnReceiveMove dcmtkscu.run_in_term( 'movescu -v -P -aem AE1 -k 0010,0010="*" -k 0008,0052="PATIENT" localhost 9999' ) # start application entity MyAE.start() MyAE.QuitOnKeyboardInterrupt()
def OnAssociateRequest(association): print "Association request received" def OnReceiveEcho(self): print print "Echo received" return True def OnReceiveFind(self, ds): for ii in range(1000): ds.PatientsName = 'titi' + str(ii) print "sending fake response: patient name: %s" % ds.PatientsName yield ds, 0xFF00 # responding to find request # create application entity MyAE = AE('localhost', 9999, [], [PatientRootFindSOPClass, VerificationSOPClass]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho MyAE.OnReceiveFind = OnReceiveFind dcmtkscu.run_in_term('findscu -v -P -aec AE1 -k 0010,0010="*" -k 0008,0052="PATIENT" localhost 9999') # start application entity MyAE.start() MyAE.QuitOnKeyboardInterrupt()
echoscu -v localhost 9999 """ import sys sys.path.append('..') import time import netdicom import dcmtkscu # call backs def OnAssociateRequest(association): print "Association request received" def OnReceiveEcho(self): print "Echo received" return True # create application entity MyAE = netdicom. AE('localhost', 9999, [], [netdicom.VerificationSOPClass]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho dcmtkscu.run_in_term('echoscu -v localhost 9999') # start application entity MyAE.start() MyAE.QuitOnKeyboardInterrupt()
for ii in range(5): ds.PatientsName = 'titi' + str(ii) print "sending fake response: patient name: %s" % ds.PatientsName print ds print yield ds, 0xFF00 # responding to find request # setup AE print 'Create AE...' MyAE = netdicom.AE('localhost', 9999, SOPSCU=[], SOPSCP=[netdicom.VerificationSOPClass, netdicom.ModalityWorklistInformationFindSOPClass] ) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho MyAE.OnReceiveFind = OnReceiveFind # Start modality simulator dcmtkscu.run_in_term( 'findscu -v -W -aec AE1 -k 0010,0020="*" -k 0010,0040="*" -k 0010,0030="*" ' '-k 0008,0052="PATIENT" -k 0008,0060="MR" -k 0040,0001="*" ' 'localhost 9999') # start AE print "starting AE ... " MyAE.start() print "Entering processing loop..." MyAE.QuitOnKeyboardInterrupt()