Hi Omar!
Thanks for reply.
I have done same thing . but still images are not being downloaded.
This is the complete code.
Code: Select all
@implementation SITViewController
static Uint8 findUncompressedPC(const OFString& sopClass,
DcmSCU& scu)
{
Uint8 pc;
pc = scu.findPresentationContextID(sopClass, UID_LittleEndianExplicitTransferSyntax);
if (pc == 0)
pc = scu.findPresentationContextID(sopClass, UID_BigEndianExplicitTransferSyntax);
if (pc == 0)
pc = scu.findPresentationContextID(sopClass, UID_LittleEndianImplicitTransferSyntax);
return pc;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSMutableArray *tempArray = [[NSMutableArray alloc]init];
self.resultArray = tempArray;
[tempArray release];
[self performSelectorInBackground:@selector(startStoreSCP) withObject:nil];
[self performSelector:@selector(downloadImage) withObject:nil afterDelay:10];
}
-(void)startStoreSCP
{
// DicomEmpfangen *scp; // put this in a headerfile if you use a class and not a main!
scp = new DicomEmpfangen();
scp->setPort(USERPEERPORT);
scp->setAETitle(MOVEAPPLICATIONTITLE);
NSString *pathname = [[NSBundle mainBundle] pathForResource:@"storescp" ofType:@"cfg"] ;
const OFString path = (char * )[pathname UTF8String];
if (scp->loadAssociationCfgFile(path).good())
{
NSLog(@"SCP-Config-File gefunden :-)");
NSLog(@"dime-timeout: %@", scp->getDIMSETimeout());
if (scp->setAndCheckAssociationProfile("Default").good())
{
NSLog(@"listen gestartet um");
scp->setDIMSETimeout(ULONG_MAX);
scp->setDIMSEBlockingMode(DIMSE_NONBLOCKING);
if (scp->getDIMSEBlockingMode() == DIMSE_NONBLOCKING )
{
NSLog(@"scp is in non-blocking mode: ");
scp->setConnnectionTimeout(ULONG_MAX);
if (scp->getDIMSEBlockingMode() == DIMSE_BLOCKING )
NSLog(@"2nd try: scp is in blocking mode: ");
else NSLog(@"scp is still in non-blocking mode: ");
}
else {
NSLog(@"scp is in blocking mode: ");
}
if (scp->listen().bad())
{
NSLog(@"error during listening!");
}
//NSLog(@"listen stops at: " << QTime::currentTime();
NSLog(@"listen stops at: ");
}
}
else
NSLog(@"SCP-Config file not found :-(");
}
-(void) downloadImage
{
// Setup DICOM connection parameters
OFLog::configure(OFLogger::DEBUG_LOG_LEVEL);
DcmSCU scu;
// set AE titles
scu.setAETitle(APPLICATIONTITLE); //calling Application Entity title
//scu.setAETitle(MOVEAPPLICATIONTITLE); //calling Application Entity title
scu.setPeerHostName(PEERHOSTNAME);
scu.setPeerPort(PEERPORT);
scu.setPeerAETitle(PEERAPPLICATIONTITLE); //called Application Entity title
// Use presentation context for FIND/MOVE in study root, propose all uncompressed transfer syntaxes
OFList<OFString> ts;
ts.push_back(UID_LittleEndianExplicitTransferSyntax);
ts.push_back(UID_BigEndianExplicitTransferSyntax);
ts.push_back(UID_LittleEndianImplicitTransferSyntax);
//ts.push_back(UID_JPEGLSLosslessTransferSyntax);
scu.addPresentationContext(UID_FINDStudyRootQueryRetrieveInformationModel, ts);
scu.addPresentationContext(UID_MOVEStudyRootQueryRetrieveInformationModel, ts);
//scu.addPresentationContext(UID_GETStudyRootQueryRetrieveInformationModel, ts);
//ts.push_back(UID_JPEGLSLosslessTransferSyntax);
scu.addPresentationContext(UID_VerificationSOPClass, ts);
// scu.addPresentationContext(UID_SecondaryCaptureImageStorage, ts);
// ts.push_back(UID_JPEG2000TransferSyntax);
// Initialize network
OFCondition result = scu.initNetwork();
if (result.bad())
{
DCMNET_ERROR("Unable to set up the network: " << result.text());
return ;
}
// Negotiate Association
result = scu.negotiateAssociation();
if (result.bad())
{
DCMNET_ERROR("Unable to negotiate association: " << result.text());
return ;
}
// Let's look whether the server is listening:
// Assemble and send C-ECHO request
result = scu.sendECHORequest(0);
if (result.bad())
{
DCMNET_ERROR("Could not process C-ECHO with the server: " << result.text());
return ;
}
//Construction et envoi d'une requete C-FIND, pour trouver les examens
//FINDResponses findResponses;
OFList<QRResponse*> OFfindResponses;
DcmDataset req;
req.putAndInsertOFStringArray ( DCM_QueryRetrieveLevel, "IMAGE");
req.putAndInsertOFStringArray ( DCM_SeriesInstanceUID, "1.2.840.113747.1078798801.1964.3000.1762082110160.0");
req.putAndInsertOFStringArray ( DCM_StudyInstanceUID, "1.3.12.2.1107.5.2.12.21264.4.0.8969333128827685" );
req.putAndInsertOFStringArray ( DCM_PatientID, "7Q6,^71" );
req.putAndInsertOFStringArray ( DCM_SOPInstanceUID, "1.2.840.113747.1078798801.1964.3000.1762082110160.6");
//CONSTRUCTION DE LA REQUETE
//Avec les numéro ID des series selectionnées
// OFString OFNumeroIDStudy = OFNumeroIDStudy;
// req.putAndInsertOFStringArray(DCM_StudyInstanceUID, OFNumeroIDStudy);
T_ASC_PresentationContextID presID = findUncompressedPC(UID_FINDStudyRootQueryRetrieveInformationModel, scu);
// presID = findUncompressedPC(UID_FINDStudyRootQueryRetrieveInformationModel, scuN);
if (presID == 0)
{
DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND");
return ;
}
result = scu.sendFINDRequest(presID, &req, &OFfindResponses);
if (result.bad())
{
DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND");
return ;
}
else
{
}
presID = findUncompressedPC(UID_MOVEStudyRootQueryRetrieveInformationModel, scu);
if (presID == 0)
{
DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND");
return ;
}
OFListIterator(QRResponse*) instance = OFfindResponses.begin();
Uint32 instanceCount = 1;
OFBool failed = OFFalse;
while (instance != OFfindResponses.end() && result.good())
{
// Pour chaque boucle en réponse, soit chaque examen, toutes les images seront récupérées
OFList<RetrieveResponse*> moveResponses; //MOVEResponses moveResponses;
if ( (*instance)->m_dataset != NULL) //Il faut etre certain que ce n'est pas la derniere réponse, elle ne contient pas d'information
{
OFString imageID;
result = (*instance)->m_dataset->findAndGetOFStringArray(DCM_SOPInstanceUID, imageID);
if (result.good())
{
OFString OFmonAet = OFmonAet;
ts.push_back(UID_JPEGLSLosslessTransferSyntax);
scu.addPresentationContext(UID_MOVEStudyRootQueryRetrieveInformationModel, ts);
result = scu.sendMOVERequest(presID, MOVEAPPLICATIONTITLE, &req, &moveResponses);
if (result.good())
{
DCMNET_INFO("Received Image #" << std::setw(7) << instanceCount << ": " << imageID);
instanceCount++;
}
}
}
instance++;
}
if (result.bad())
{
DCMNET_ERROR("Unable to retrieve all studies: " << result.text());
}
while (!OFfindResponses.empty())
{
delete OFfindResponses.front();
OFfindResponses.pop_front();
}
scu.closeAssociation(DCMSCU_RELEASE_ASSOCIATION);
}
and its output is like this :
2012-05-29 12:23:28.260 PACS Cam[14022:4a03] SCP-Config-File gefunden
2012-05-29 12:23:28.261 PACS Cam[14022:4a03] dime-timeout: (null)
2012-05-29 12:23:28.265 PACS Cam[14022:4a03] listen gestartet um
2012-05-29 12:23:28.265 PACS Cam[14022:4a03] scp is in non-blocking mode:
2012-05-29 12:23:28.266 PACS Cam[14022:4a03] scp is still in non-blocking mode:
....
..
...
...
===================== OUTGOING DIMSE MESSAGE ====================
D: Message Type : C-MOVE RQ
D: Presentation Context ID : 3
D: Message ID : 3
D: Affected SOP Class UID : MOVEStudyRootQueryRetrieveInformationModel
D: Data Set : present
D: Priority : low
D: Move Destination : PACS
D: -----------------------------------------------------------------
D: # Dicom-Data-Set
D: # Used TransferSyntax: Little Endian Explicit
D: (0008,0018) UI [1.2.840.113747.1078798801.1964.3000.1762082110160.6======================= END DIMSE MESSAGE =======================
D: DcmDataset::read() TransferSyntax="Little Endian Implicit"
I: Received C-MOVE Response
D: ===================== INCOMING DIMSE MESSAGE ====================
D: Message Type : C-MOVE RSP
D: Presentation Context ID : 3
D: Message ID Being Responded To : 3
D: Affected SOP Class UID : MOVEStudyRootQueryRetrieveInformationModel
D: Remaining Suboperations : 0
D: Completed Suboperations : 1
D: Failed Suboperations : 0
D: Warning Suboperations : 0
D: Data Set : none
D: DIMSE Status : 0xff00: Pending
D: ======================= END DIMSE MESSAGE =======================
D: Handling C-MOVE Response
D: One or more pending C-MOVE responses
D: DcmDataset::read() TransferSyntax="Little Endian Implicit"
I: Received C-MOVE Response
D: ===================== INCOMING DIMSE MESSAGE ====================
D: Message Type : C-MOVE RSP
D: Presentation Context ID : 3
D: Message ID Being Responded To : 3
D: Affected SOP Class UID : MOVEStudyRootQueryRetrieveInformationModel
D: Remaining Suboperations : none
D: Completed Suboperations : 1
D: Failed Suboperations : 0
D: Warning Suboperations : 0
D: Data Set : none
D: DIMSE Status : 0x0000: Success
D: ======================= END DIMSE MESSAGE =======================
D: Handling C-MOVE Response
D: Received final C-MOVE response, no more C-MOVE responses expected
I: Received Image # 1: 1.2.840.113747.1078798801.1964.3000.1762082110160.6
I: Releasing Association
Can u plz tell what are the mistakes which I am doing here ?