# include“ltdic.h”
LDicomAssociate* LDicomNet: GetAssociate (L_VOID)
返回DICOM Network对象的DICOM关联。该函数可在pac成像工具包。
与DICOM Network对象相关联的DICOM关联。
在SCU和SCP之间传输任何DICOM消息或数据之前,必须在SCU和SCP之间建立DICOM关联。有关创建DICOM关联的更多信息,请参见创建DICOM关联连接.
当不再需要DICOM协会时,应该关闭它。有关更多信息,请参阅关闭一个DICOM关联连接.
必需的dll和库
Win32, x64
名称空间LDicomNet_GetAssociate_Namespace
{
//记录消息
//这个实现记录到控制台和调试窗口
LogMessage(tsar *szMsg)
{
wprintf(文本(“\ n”));
wprintf (szMsg);
OutputDebugStringW(文本(“\ n”));
OutputDebugStringW (szMsg);
}
// *******************************************************************************************
//客户端类
//
//用于连接到服务器的类
// *******************************************************************************************
类CMyClient:公共LDicomNet
{
公共:
CMyClient(L_INT32): LDicomNet(NULL, nMode)
{
m_waitEvent = CreateEvent(NULL, TRUE, TRUE, TEXT(“ClientEvent”));
ResetEvent (m_waitEvent);
}
~ CMyClient (无效)
{
CloseHandle (m_waitEvent);
}
/ /客户端
L_VOID OnConnect (L_INT error);
OnReceiveAssociateAccept (LDicomAssociate *pPDU);
L_VOID OnReceiveReleaseResponse ();
等待(DWORD超时= 5000);
私人:
处理m_waitEvent;
};
//继续发送消息,直到hEvent发出信号,我们的超时
//如果hEvent有信号则返回TRUE
//如果超时返回FALSE
L_BOOL消息循环(
处理hEvent,//需要等待的句柄
DWORD超时//超时时间,单位为毫秒
)
{
DWORD dwStart = GetTickCount();
MSG MSG = {0};
挥发性L_BOOL bRunForever = TRUE;
而(bRunForever)
{
如果(PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
{
TranslateMessage(味精);
DispatchMessage(味精);
}
如果(WaitForSingleObject(hEvent, 0) == WAIT_OBJECT_0)
{
ResetEvent (hEvent);
返回真正的;
}
DWORD dwCurrent = GetTickCount();
如果((dwCurrent - dwStart) > timeout)
{
返回虚假的;
}
}
返回真正的;
}
CMyClient::OnConnect(L_INT error)
{
L_TCHAR szMsg[200] = {0};
wsprintf (szMsg文本(“CMyClient:: OnConnect: nError [% d]”), nError);
LogMessage (szMsg);
}
CMyClient::OnReceiveAssociateAccept (LDicomAssociate *pPDU)
{
UNREFERENCED_PARAMETER (pPDU);
SetEvent (m_waitEvent);
LogMessage(文本(“CMyClient:: OnReceiveAssociateAccept”));
}
L_VOID CMyClient: OnReceiveReleaseResponse ()
{
SetEvent (m_waitEvent);
LogMessage(文本(“CMyClient:: OnReceiveReleaseResponse”));
}
CMyClient::Wait(DWORD超时)
{
L_BOOL bRet = MessageLoop(m_waitEvent, timeout);
返回bRet;
}
// *******************************************************************************************
//服务器连接类
//
//当客户端连接时,CMyServer创建一个CMyServerConnection类的新实例
//并接受连接。
// *******************************************************************************************
类CMyServerConnection:公共LDicomNet
{
公共:
CMyServerConnection(L_INT32): LDicomNet(NULL, nMode)
{
}
~ CMyServerConnection (无效)
{
}
/ /服务器
(LDicomAssociate *pPDU);
L_VOID OnReceiveReleaseRequest ();
};
#定义SIZEINWORD (p)运算符(p) /运算符(L_TCHAR)
L_VOID CMyServerConnection::OnReceiveAssociateRequest
{
LogMessage(文本(“\ tCMyServerConnection:: OnReceiveAssociateRequest”));
//检查版本,如果不是1,拒绝它
如果(pPDU->GetVersion() != 1)
{
LogMessage(文本(“\ tCMyServerConnection:: SendAssociateReject”));
SendAssociateReject (
PDU_REJECT_RESULT_PERMANENT,
PDU_REJECT_SOURCE_USER,
PDU_REJECT_REASON_UNKNOWN
);
}
其他的
{
LDicomAssociate DicomAssociate(假);
//复制接收到的表示对象
//回复我们只支持接收到的hPDU的第一个传输语法
L_TCHAR szTransfer[PDU_MAX_UID_SIZE+1] = {0};
[PDU_MAX_UID_SIZE+1] = {0};
L_INT iPresentationCount = pPDU->GetPresentationCount();
为(L_UCHAR i = 0;我< iPresentationCount;我+ +)
{
L_UCHAR nId = pPDU->GetPresentation(i);
pPDU->GetTransfer(nId, 0, szTransfer, PDU_MAX_UID_SIZE+1);
L_UCHAR nResult = PDU_ACCEPT_RESULT_SUCCESS;
pPDU->GetAbstract(nId, szAbstract, PDU_MAX_UID_SIZE+1);
DicomAssociate。AddPresentation(nId, nResult, szAbstract);
DicomAssociate。AddTransfer(nId, szTransfer);
}
LogMessage(文本(“\ tCMyServerConnection:: SendAssociateAccept”));
SendAssociateAccept (&DicomAssociate);
}
}
L_VOID CMyServerConnection: OnReceiveReleaseRequest ()
{
LogMessage(文本(“\ tCMyServerConnection:: OnReceiveReleaseRequest”));
LogMessage(文本(“\ tCMyServerConnection:: SendReleaseResponse”));
SendReleaseResponse ();
}
// *******************************************************************************************
//服务器类
//
//监听连接
//当客户端连接时,这个类创建一个CMyServerConnection并接受连接
// *******************************************************************************************
类CMyServer:公共LDicomNet
{
公共:
CMyServer(L_INT32): LDicomNet(NULL, nMode)
{
m_pServerConnection = NULL;
}
~ CMyServer (无效)
{
如果(m_pServerConnection = NULL)
{
删除m_pServerConnection;
}
}
L_VOID OnAccept (L_INT error);
L_VOID OnClose (L_INT nError, LDicomNet *pServerConnection);
CMyServerConnection * m_pServerConnection;
};
CMyServer::OnAccept(L_INT error)
{
LogMessage(文本(“\ tCMyServer:: OnAccept”));
如果(错误!= DICOM_SUCCESS)
{
返回;
}
如果(m_pServerConnection = NULL)
{
删除m_pServerConnection;
m_pServerConnection = NULL;
}
m_pServerConnection =新CMyServerConnection (DICOM_SECURE_NONE);
如果(m_pServerConnection == NULL)
{
返回;
}
LDicomNet::Accept(m_pServerConnection);
如果(错误!= DICOM_SUCCESS)
{
删除m_pServerConnection;
返回;
}
}
L_VOID CMyServer::OnClose(L_INT nError, LDicomNet *pServerConnection)
{
UNREFERENCED_PARAMETER (nError);
LogMessage(文本(“\ tCMyServer:: OnClose”));
如果(m_pServerConnection == pServerConnection)
{
m_pServerConnection = NULL;
}
删除(CMyServerConnection *) pServerConnection;
}
// *******************************************************************************************
//从这里开始
// *******************************************************************************************
#定义WaitForProcessing() \
{\
如果(! client.Wait ()) \
{\
LogMessage(文本(“超时:客户端。连接”));\
nRet = DICOM_ERROR_NET_TIME_OUT;\
转到清理;\
} \
}
(CMyClient* pDicomNet)
{
L_TCHAR szTemp[100] = {0};
L_UCHAR nID = 0;
//获取客户端计算机连接的关联对象
LDicomAssociate *pDicomAssociate = pDicomNet->GetAssociate();
//找到这个关联中UID_VERIFICATION_CLASS的id
//如果它是由协会支持的
nID = pDicomAssociate->FindAbstract(UID_VERIFICATION_CLASS);
如果(nID == 0)
{
LogMessage(文本(“这个协会不支持!”));
}
其他的
{
wsprintf (szTemp文本("在以下演示文稿id中找到:\n %d")),国家免疫日;
LogMessage (szTemp);
nID = pDicomAssociate->FindNextAbstract(nID, UID_VERIFICATION_CLASS);
而(nID != 0)
{
wsprintf (szTemp文本(“% d \ n”)),国家免疫日;
LogMessage (szTemp);
}
}
}
L_INT LDicomNet_GetAssociateExample ()
{
L_INT nRet = DICOM_SUCCESS;
LogMessage(文本("\n\n *** LDicomNet_GetAssociateExample ***"));
L_TCHAR *pszServerAddress = TEXT(“127.0.0.1”);
L_UINT uServerPort = 104;
LDicomNet:启动();
CMyClient客户机(DICOM_SECURE_NONE);
CMyServer服务器(DICOM_SECURE_NONE);
LogMessage(文本(“\ tCMyServer:听”));
nRet = server。监听(pszServerAddress, uServerPort, 5);
LogMessage(文本(“CMyClient:连接”));
客户端。Connect(NULL, 0, pszServerAddress, uServerPort);
如果(! client.Wait (2000))
{
如果(! client.IsConnected ())
{
LogMessage(文本(“超时:客户端。连接”));
nRet = DICOM_ERROR_NET_TIME_OUT;
转到清理;
}
}
如果(nRet == DICOM_SUCCESS)
{
//创建关联类作为请求
LDicomAssociate dicomAssociateRequest(真正的);
dicomAssociateRequest.Default ();
//发送A-Associate-RQ消息
dicomAssociateRequest。SetCalled(文本(“LEAD_SERVER”));
dicomAssociateRequest。SetCalling(文本(“LEAD_CLIENT”));
LogMessage(文本(“CMyClient:: SendAssociateRequest”));
nRet = client.SendAssociateRequest(&dicomAssociateRequest);
如果(! client.Wait (5000))
{
LogMessage(文本(“超时:客户端。连接”));
nRet = DICOM_ERROR_NET_TIME_OUT;
转到清理;
}
GetAssociateExample(客户端);
LogMessage(文本(“CMyClient:: SendReleaseRequest”));
client.SendReleaseRequest ();
WaitForProcessing ();
}
清理:
LogMessage(文本(“CMyClient:接近”));
client.Close ();
client.Wait (1000);
LogMessage(文本(“\ tCMyServer:接近”));
server.Close ();
LDicomNet:关闭();
返回nRet;
}
}
帮助收藏
光栅net|C API|c++类库|HTML5 JavaScript
文档net|C API|c++类库|HTML5 JavaScript
医疗net|C API|c++类库|HTML5 JavaScript
医疗网络查看器net
188宝金博怎么下载
支持的平台上
.NET、Java、Android和iOS/macOS程序集
C API/ c++类库
HTML5 JavaScript库
您的邮件已发送给技术支持!应该有人联系!如果你的事情很紧急,请回来聊天。
聊天时间:
周一至周五,美国东部时间上午8:30至下午6:00
感谢您的反馈!
请再次填写表格,开始新的聊天。
所有代理目前都离线。
聊天时间:
星期一至星期五
美国东部时间上午8:30 -下午6点
如需与我们联系,请填写此表格,我们将通过电子邮件与您联系。