先到官网下载DCMTK的工具Download DCMTK Tools - dicom.offis.de
下载后解压即可
打开cmd控制命令终端
先 cd /d C:\Users\Admin\Documents\Downloads\dcmtk-3.6.8-win64-dynamic\bin 进入DCMTK的bin文件夹
echoscu localhost 4242 与本机的DICOM服务器建立关联
echoscu localhost 4242 -ll info 查看关联的信息
I: Requesting Association
I: Association Accepted (Max Send PDV: 16372)
I: Sending Echo Request (MsgID 1)
I: Received Echo Response (Success)
I: Releasing Association
关联建立成功
echoscu localhost 4242 -ll debug > "C:\Users\Admin\Documents\Downloads\dicom.log"
查看一下debug信息,放置在dicom.log里
再log日志文件里可以看到
D: Calling Application Name: ECHOSCU scu指使用者 Requesting发起者我的AET,这是一个默认值
D: Called Application Name: ANY-SCP scp指服务提供者 对方的AET,这也是个默认值
I: Received Echo Response (Success) 接受关联成功
这里我们可以设置一下Orthanc的配置文件 我的位置为D:\Orthanc Server\Configuration\orthanc.json 右键用notepad++打开。里面有一项
这里如果设置为true,再重启Orthanc的服务器(在服务里面或者任务管理器里的服务列表重启Orthanc服务即可),就会检查上面SCP的 AET是否正确,如果不正确,则关联会被拦截
这一项就是SCP的AET
然后我们再在终端内指定服务方的AET
echoscu localhost 4242 -ll info -aec ORTHANC (ORTHANC 不区分大小写) 可以关联成功
但如果
echoscu localhost 4242 -ll info -aec test 则会提示 Association Rejected 拒绝访问
aec:被呼叫的对方的AE标题,在这里指代服务器标题
aet:呼叫着的AE标题,这里指客户端标题
当DicomCheckCalledAet设定为true,我们使用默认的echoscu localhost 4242 -ll info指令便不会再成功,因为默认的aec为ANY-SCP,这是不被允许访问的aec
本机访问Drthanc服务器可以MyOrthanc » Lookup studies 或 Orthanc Explorer 127.0.0.1也是本机的ip地址
补充一点,在C#中的实现代码
/// <summary>
/// 使用C-Echo SCU/SCP测试与Host服务器的通信是否正常
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void btnCommWithPacs_Click(object sender, RoutedEventArgs e)
{
var client = DicomClientFactory.Create("172.20.111.101", 4242, false, "SCU", "ANY-SCP");
client.ClientOptions.AssociationRequestTimeoutInMs = (int)TimeSpan.FromMinutes(5).TotalMilliseconds; // 设置关联请求超时时间为5分钟
DicomCEchoResponse response = null; // 用于存储响应
DicomRequest.OnTimeoutEventArgs timeout = null; // 用于存储超时事件
var request = new DicomCEchoRequest
{
OnResponseReceived = (req, res) => response = res, // 响应接收事件
OnTimeout = (sender, args) => timeout = args // 超时事件
};
await client.AddRequestAsync(request); // 添加C-Echo请求
try
{
await client.SendAsync(); // 发送请求
// 验证响应不为空
Assert.NotNull(response);
// 验证响应状态是成功
Assert.Equal(DicomStatus.Success, response.Status);
// 验证没有发生超时
Assert.Null(timeout);
lbCommResult.Content = response.Status;
}
catch (Exception ex)
{
lbCommResult.Content = "fail";
}
}