本帖最后由 medimage 于 2015-12-4 21:26 编辑
七、dcmnet程序库
dcmnet是一个网络库及可用工具。该模块包含了实现DICOM网络通信的所有函数集,即:DICOM上层有限状态机(DICOM Upper Layer Finite State Machine),关联控制服务元素(Association Control Service Element, ACSE)以及DICOM消息服务元素(DICOM Message Service Element, DIMSE)。
主要接口:该模块的主要接口包括在文件assoc.h和dimse.h中定义的大量结构和函数。
--assoc.h: 这个文件包含程序,为DICOM应用提供关联管理。它维护描述活动关联的结构,提供对关联特定信息的访问。也提供程序帮助关联协议association negotiation(presentation contexts, abstract syntaxes, transfer syntaxes, maximum PDU length, and other extended negotiation)。该包使用了DICOM上层机制接收/发送关联请求/响应。每一个活动的关联由T_ASC_Association结构表示,包含了所有相关的信息。模块前缀ASC_。
--dimse.h: 这个文件包含程序,为DICOM应用提供dimse层的服务。 工具: --echoscu: DICOM verification (C-ECHO) SCU --findscu: DICOM query (C-FIND) SCU --movescu: DICOM retrieve (C-MOVE) SCU --storescp: DICOM storage (C-STORE) SCP --storescu: DICOM storage (C-STORE) SCU --termscu: DICOM termination SCU 举例: --一个简单的Echo SCU(Verification Service Class SCU)。大多数错误处理代码省去了,在Win32上的特定代码如WinSock初始化也省去了。
T_ASC_Network *net; // network struct, contains DICOM upper layer FSM etc.
ASC_initializeNetwork(NET_REQUESTOR, 0, 1000 /* timeout */, &net); T_ASC_Parameters *params; // parameters of association request ASC_createAssociationParameters(¶ms, ASC_DEFAULTMAXPDU); // set calling and called AE titles ASC_setAPTitles(params, "ECHOSCU", "ANY-SCP", NULL);
// the DICOM server accepts connections at server.nowhere.com port 104
ASC_setPresentationAddresses(params, "localhost", "server.nowhere.com:104");
// list of transfer syntaxes, only a single entry here
const char* ts[] = { UID_LittleEndianImplicitTransferSyntax }; // add presentation context to association request ASC_addPresentationContext(params, 1, UID_VerificationSOPClass, ts, 1); // request DICOM association T_ASC_Association *assoc; if (ASC_requestAssociation(net, params, &assoc).good()) { if (ASC_countAcceptedPresentationContexts(params) == 1) { // the remote SCP has accepted the Verification Service Class DIC_US // generate next message ID DIC_US status; // DIMSE status of C-ECHO-RSP will be stored here DcmDataset *sd = NULL; // status detail will be stored here // send C-ECHO-RQ and handle response DIMSE_echoUser(assoc, id, DIMSE_BLOCKING, 0, &status, &sd); delete sd; // we don't care about status detail } } ASC_releaseAssociation(assoc); // release association ASC_destroyAssociation(&assoc); // delete assoc structure ASC_dropNetwork(&net); // delete net structure
|