On Jun 26, 11:11 pm, Kvnz <crk...@gmail . com > wrote:
> is there any way of validating if a modality has the dicom print
> service available?
> If it is possible, how can i do it? is there any special software?
>
> thank you!
--------------------------------------------------------------------------------
C-ECHO Example
--------------------------------------------------------------------------------
The example below illustrates what an Application developed with the
ImageTransport MD looks like. C-ECHO is the simplest DIMSE Message. It
is similar to the `ping' command in network operating systems. The
example shows how a DICOM Association is created and how DIMSE
Messages are sent through the Association. As stated earlier, there is
no explicit library initialization or separate configuration file. The
following examples are complete and functional.
SCP case
In this example, there is no apparent activity in SCP because C-ECHO
requests are automatically responded to by MSM. SCU is denied
Association if it is not in the list of allowable AE. If the SCU is an
allowed Association and there is no error in the data received over
the network, then a success Response is automatically sent to the SCU
and the Association is closed, at the request of SCU.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "DataDict.h"
#include "dc_sdk.h"
int main (int argc, char **argv)
{
int rc; /* return code */
int port; /* DICOM communication port */
DCObj msm; /* Message State Machine */
int sop;
DCObj msg;
DCMsmScpInfo scpInfo; /* SCP connection information */
char *aeTitleAccept [] = { /* list of acceptable AE Titles
*/
" ", NULL
};
/* check argument list */
if (argc < 2) {
printf ("Usage : %s <port>\n", *argv);
return (1);
}
/* parse arguments */
port = atoi (*++argv); argc--;
/* provide username and password */
rc = DCInit ("EVAL", "PASSWORD");
if (rc != MAIN_ERR_NONE)
return (rc);
/* create DIMSE Message State Machine */
rc = DCMsmCreate (&msm, "DICOM SDK ESCP", MSM_TYPE_SCP,
port);
if (rc != MSM_ERR_NONE)
return (rc);
/* fill in SCP connection information */
scpInfo.structSize = sizeof(DCMsmScpInfo);
scpInfo.aeTitleAccept = aeTitleAccept;
scpInfo.sopAccept[0] = MED_DCM_SOP_VERIFICATION;
scpInfo.sopAccept[1] = MED_DCM_SOP_NULL; // null terminator
strcpy (scpInfo.appCtxName, "1.2.840.10008.3.1.1.1");
strcpy (scpInfo.implClassUid, "2.840.1015.1.17.1.2");
strcpy (scpInfo.implVerName, "ESCP 1.00.000");
scpInfo.maxPduLen = 16 * 1024;
scpInfo.artimTimeout = 45;
scpInfo.readTimeout = 30;
scpInfo.writeTimeout = 15;
/* open Association as SCP, called only once at startup */
printf ("Server idle, waiting ...\n");
DCMsmScpAssoOpen (&msm, &scpInfo);
/* read Messages forever */
while (1) {
/* read Messages via MSM */
rc = DCMsmRead (&msm, &sop, &msg);
/* print Association information to console */
if (rc == MSM_RC_ASSOCIATE_RQ)
DCMsmAssoInfoPrint (&msm, stdout);
/* discard all Messages */
if (rc == MSM_RC_MSG)
DCMsgDestroy (&msg);
}
return (0);
}
SCU Case
In this example, SCU requests a connection from SCP. On successful
connection, a C-ECHO-RQ Message is created and sent to SCP. The
connection is closed upon receipt of Response.
int
main (
int argc,
char **argv
)
{
char *hostname; /* hostname of target SCP*/
int port; /* port for target SCP */
int rc; /* return code */
int sop; /* sop for read/write */
int status; /* status in Element (0000,0900) */
DCObj msm; /* Message State Machine */
DCObj echoRq; /* C-ECHO-RQ Message */
DCObj echoRsp; /* C-ECHO-RSP Message */
DCObj elem; /* generic Element */
DCMsmScuInfo scuInfo; /* SCU connection info */
if (argc < 3) {
printf (" Usage: %s <hostname> <port>\n", *argv);
return (0);
}
/* parse command line arguments */
hostname = *++argv;
port = atoi (*++argv);
/* provide username and password */
rc = DCInit ("EVAL", "PASSWORD");
if (rc != MAIN_ERR_NONE)
return (rc);
/* create DIMSE Message State Machine */
rc = DCMsmCreate (&msm, "DICOM SDK ESCU", MSM_TYPE_SCU, port);
if (rc != MAIN_ERR_NONE)
return (rc);
/* fill in SCU connection information */
scuInfo.structSize = sizeof(DCMsmScuInfo);
strcpy (scuInfo.hostname, hostname);
strcpy (scuInfo.calledAeTitle, "DICOM SDK SSCP");
scuInfo.sop[0] = MED_DCM_SOP_VERIFICATION;
scuInfo.sop[1] = MED_DCM_SOP_NULL; /* null terminator */
strcpy (scuInfo.appCtxName, "1.2.840.10008.3.1.1.1");
strcpy (scuInfo.implClassUid, "2.840.1015.1.11.1.2");
strcpy (scuInfo.implVerName, "ESCU 1.00.000");
scuInfo.maxPduLen = 16 * 1024;
scuInfo.artimTimeout = 45;
scuInfo.readTimeout = 30;
scuInfo.writeTimeout = 15;
/* open Association */
if (DCMsmScuAssoOpen (&msm, scuInfo)!= MSM_RC_ASSOCIATE_AC)
return (1);
/* print Association information to console */
DCMsmAssoInfoPrint (&msm, stdout);
/* create C-ECHO-RQ message */
DCMsgCreate (&echoRq, DC_OBJ_CmdCEchoRq);
/* write C-ECHO-RQ thru MSM */
DCMsmWrite (&msm, MED_DCM_SOP_VERIFICATION, &echoRq);
DCMsgDestroy (&echoRq);
/* read C-ECHO-RSP thru MSM */
DCMsmRead (&msm, &sop, &echoRsp);
if (sop != MED_DCM_SOP_VERIFICATION) {
printf ("Invalid SOP\n");
return (2); }
/* check Status (0000,0900) */
DCMsgValueGetInt (&echoRsp, 0x00000900, &&status);
printf ((status == 0) ? "Echo successful\n" : "Echo failed\n");
/* done with C-ECHO-RSP */
DCMsgDestroy (&echoRsp);
DCMsmAssoRelease (&msm);
DCMsmDestroy (&msm);
return (0);
}