DcmFindSCU - Avoid output to console

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

DcmFindSCU - Avoid output to console

#1 Post by martinrame »

Hi, need to wrap the class DcmFindSCU in a dll to be used in a graphical application, but as the example below shows, it seems to write output to console.

How can I avoid writing to stdout?.

Code: Select all

#include <dcmtk/config/osconfig.h>
#include <dcmtk/config/cfunix.h>
#include <dcmtk/dcmnet/dfindscu.h>
#include <dcmtk/ofstd/ofstring.h>


class DcmFindSCUmyCallback: public DcmFindSCUCallback
{
public:
    DcmFindSCUmyCallback(){

    }

  virtual ~DcmFindSCUmyCallback() {}

  virtual void callback(
        T_DIMSE_C_FindRQ *request,
        int responseCount,
        T_DIMSE_C_FindRSP *rsp,
        DcmDataset *responseIdentifiers)
  {
      int r;
      r = responseCount;
  }
};

int main(int argc, char *argv[])
{
    //QCoreApplication a(argc, argv);

    DcmFindSCU * lFind = new DcmFindSCU();
    OFCondition cond = lFind->initializeNetwork(30);
    if(cond.bad())
    {
      return -1;
    }
    else
    {
      /* copy overridekeys to lOverrideKeys */
      OFList<OFString> lOverrideKeys;
      OFList<OFString> lFileNameList;

      OFString word;

      const char * abstractSyntax = UID_FINDModalityWorklistInformationModel;
      lOverrideKeys.push_back("0010,0010=RAM*");
      const char * peer = "192.168.0.129";
      unsigned int port = 104;
      const char * aet = "TEST";
      const char * aec = "SynapseDicomSCP";
      DcmFindSCUmyCallback * myCallBack = new DcmFindSCUmyCallback();
      cond = lFind->performQuery(
        peer, port,
        aet, aec,
        abstractSyntax,
        EXS_Unknown,
        DIMSE_BLOCKING,
        0,
        ASC_DEFAULTMAXPDU,
        OFFalse,
        OFFalse,
        1,
        OFFalse,
        -1,
        &lOverrideKeys,
        myCallBack
        );

      OFString temp_str;
      if (cond.bad())
      {
        DimseCondition::dump(temp_str, cond);
      }

      // destroy network structure
      cond = lFind->dropNetwork();
      if (cond.bad())
      {
       DimseCondition::dump(temp_str, cond);
      }

  }
    return 0;
}
The code above, outputs this:

Code: Select all

I: Requesting Association
I: Association Accepted (Max Send PDV: 64988)
I: ===================== OUTGOING DIMSE MESSAGE ====================
I: Message Type                  : C-FIND RQ
I: Presentation Context ID       : 1
I: Message ID                    : 1
I: Affected SOP Class UID        : FINDModalityWorklistInformationModel
I: Data Set                      : present
I: Priority                      : low
I: ======================= END DIMSE MESSAGE =======================
I: Find SCU Request Identifiers:
I: 
I: # Dicom-Data-Set
I: # Used TransferSyntax: Unknown Transfer Syntax
I: (0010,0010) PN [RAM*]                                   #   4, 1 PatientName
I: 
I: ===================== INCOMING DIMSE MESSAGE ====================
I: Message Type                  : C-FIND RSP
I: Message ID Being Responded To : 1
I: Affected SOP Class UID        : FINDModalityWorklistInformationModel
I: Data Set                      : none
I: DIMSE Status                  : 0xa700: Error: Refused - Out of resources
I: ======================= END DIMSE MESSAGE =======================
W: Status Detail:
W: 
W: # Dicom-Data-Set
W: # Used TransferSyntax: Little Endian Implicit
W: (0000,0902) LO [CFIND:SCP ExecuteDBCmd failed]          #  30, 1 ErrorComment
W: 
I: Releasing Association
That's what I want to avoid outputting to console. I want to handle it internally.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

You need to configure the (root) logger accordingly -- as described in the documentation.

There are multiple ways to avoid any output to the console. One of them is the following (add this code to the beginning of your main function):

Code: Select all

    log4cplus::SharedAppenderPtr nullapp(new log4cplus::NullAppender());
    log4cplus::Logger log = log4cplus::Logger::getRoot();
    log.removeAllAppenders();
    log.addAppender(nullapp);
Also see the following HOWTO, which has be updated right now :-)

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

#3 Post by martinrame »

Thanks Jörg, now my app works as expected.

Now a related question. Is there a way to check for processing result. It seems that cond.bad() doesn't return the expected results.

In my example, lFind->performQuery should return an error condition, but when I check for cond.bad() it returns False, that means the process was Ok. But it wansn't, the result was "(0000,0902) LO [CFIND:SCP ExecuteDBCmd failed]".

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#4 Post by Jörg Riesmeier »

performQuery() returns a status of good() if the query could be sent to the SCP, which is apparently the case in your example. The DIMSE status is available in the callback function - see DcmFindSCUDefaultCallback::callback().

Forward
Posts: 17
Joined: Mon, 2011-05-02, 11:54

#5 Post by Forward »

Is there any possibility to output to byte[] c++ ?

By the way, using parameteres how can i get PatientName
lOverrideKeys.push_back("(0008,0052)=IMAGE");
lOverrideKeys.push_back("(0010,0020)=0009703828");
lOverrideKeys.push_back("(0010,0010)");

0010,0010 should return the PatienName for that patientId but it just output no value available, but with findscu.exe it works fine

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

#6 Post by martinrame »

Forward, you are enclosing the tag between parenthesis. Did you try without them?.

Example:

Code: Select all

lOverrideKeys.push_back("0008,0052=IMAGE");
lOverrideKeys.push_back("0010,0020=0009703828");
lOverrideKeys.push_back("0010,0010"); 

Forward
Posts: 17
Joined: Mon, 2011-05-02, 11:54

#7 Post by Forward »

@martinrame, Didn't worked

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest