Skip to content

gonetdicom

ReleaseCIGoDoc

gonetdicom 实现 DICOM 网络协议和 DICOMweb(PS3.18)事务。godicom 关心的是一个数据集的字节,gonetdicom 关心的是把它们在机器之间搬动。

bash
go get github.com/godicom-dev/gonetdicom@latest
gonetdicom
 └── github.com/godicom-dev/godicom

数据集和像素 I/O 来自 godicom;gonetdicom 负责 Upper Layer PDU、DIMSE command set、关联协商,以及 HTTP DICOMweb。DIMSE 行为与 pynetdicom 对齐,以 git submodule 形式复用它的夹具;DICOMweb 遵循 PS3.18。

职责
aeApplication Entity —— 以 SCU 或 SCP 建立关联、TLS、角色选择、用户身份
dimseDIMSE command set,C- 与 N- 服务
pduUpper Layer PDU 与 PDV 分片
dicomwebWADO-RS / STOW-RS / QIDO-RS 客户端,以及一个源服务器 MVP
status具名的 DIMSE 状态常量

日常要写的东西几乎都在 ae 里。

两种形态

作为 SCU —— 由你发起。ae.Dial 协商一个关联并返回 *ae.Association,你在它上面发 DIMSE 消息:

go
assoc, err := ae.Dial(ctx, ae.Config{AETitle: "MYSCU"}, "pacs.example:11112", "ANY-SCP")
if err != nil {
	log.Fatal(err)
}
defer assoc.Abort()

if err := assoc.CEcho(ctx); err != nil {
	log.Fatal(err)
}
if err := assoc.Release(ctx); err != nil {
	log.Fatal(err)
}

作为 SCP —— 由你接受。ae.Serve 在一个 listener 上阻塞,把请求分派给你配置的 handler:

go
err := ae.Serve(ctx, ln, ae.ServerConfig{
	AETitle:                  "STORESCP",
	AcceptedAbstractSyntaxes: ae.AllStorageSOPClasses,
	OnCStore:                 handleStore,
})

服务

服务SCU 方法SCP handler
C-ECHOCEcho内置
C-STORECStoreOnCStore
C-FINDCFindOnCFind
C-MOVECMoveOnCMove
C-GETCGetOnCGet
C-CANCELCCancel
N-EVENT-REPORTNEventReportOnNEventReport
N-GETNGetOnNGet
N-SETNSetOnNSet
N-ACTIONNActionOnNAction
N-CREATENCreateOnNCreate
N-DELETENDeleteOnNDelete

本站相关页面

日志

默认静默,等同于不去设 pynetdicom 的 debug_loggerConfig/Client 上的 logger 优先于 context 里的:

go
assoc, err := ae.Dial(ctx, ae.Config{AETitle: "MYSCU", Logger: logger}, addr, "ANY-SCP")

ctx = gonetdicom.WithLogger(ctx, logger) // shared with godicom.ReadFileContext etc.

LevelDebug 下,AE 会记录 PDU 收发和 DIMSE 命令摘要,属性键固定:componentcalling_aecalled_aepdu_type_namecommand_namepc_idmessage_idstatus

对着真实 PACS 测试

一个可选的浸泡测试,除非环境变量指明了 PACS,否则跳过:

bash
GONETDICOM_PACS_ADDR=host:11112 GONETDICOM_PACS_AE=ANY-SCP \
  go test -tags=integration ./ae -run TestIntegrationCEchoPACS -v

仓库文档

基于 MIT 许可证发布。