Skip to content

Commit

Permalink
adding store-scu
Browse files Browse the repository at this point in the history
  • Loading branch information
knopkem committed Sep 21, 2020
1 parent 40a75b3 commit 7f8a9eb
Show file tree
Hide file tree
Showing 14 changed files with 846 additions and 11 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ include(CMake/dcmtkPrepare.cmake NO_POLICY_SCOPE)
# dcmimage dcmjpeg dcmjpls dcmtls dcmnet
# CACHE STRING "List of modules that should be built.")

set(DCMTK_MODULES ofstd oflog dcmdata dcmnet
set(DCMTK_MODULES ofstd oflog dcmdata dcmnet dcmjpeg dcmjpls dcmimage dcmimgle
CACHE STRING "List of modules that should be built.")

#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -88,7 +88,7 @@ add_library(${PROJECT_NAME} SHARED

# Define dependency libraries
#----------------------------
target_link_libraries(${PROJECT_NAME} dcmnet dcmdata oflog ofstd)
target_link_libraries(${PROJECT_NAME} ${DCMTK_MODULES})

# Gives our library file a .node extension without any "lib" prefix
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
Expand Down
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ Nodejs native addon for DICOM DIMSE services using the DCMTK DICOM c++ toolkit.
* C-Find-scu
* C-Move-scu
* C-Get-scu
* C-Store-scu
* C-Store-scp

# Roadmap:
* C-Store-scu
* extended characterSet support
* JPEG 2000 support (c-store scu)

## How to install
This package uses prebuild to fetch precompiled binaries, so provided your platform is supported, all you need to do is:
Expand All @@ -27,6 +28,9 @@ Otherwise install will try to compile the sources for your platform, you will ne

## Examples

run the examples:
```npm run example:[echo|find|get|move|store]```

# Store-SCP
```
const dimse = require('dicom-dimse-native');
Expand All @@ -38,7 +42,7 @@ dimse.startScp(JSON.stringify(
"ip" : "127.0.0.1",
"port": "9999"
},
"storagePath": "./data"
"storagePath": "./data" // Directory where incoming DICOM files will be stored
}
), (result) => {
try {
Expand Down Expand Up @@ -100,7 +104,7 @@ dimse.getScu(JSON.stringify(
"ip" : "127.0.0.1",
"port": "5678"
},
"storagePath": "./data"
"storagePath": "./data" // Directory where incoming DICOM files will be stored
"tags" : [
{
"key": "0020000D",
Expand All @@ -122,6 +126,32 @@ dimse.getScu(JSON.stringify(
});
```

# Store-SCU
```
dimse.storeScu(JSON.stringify(
{
"source": {
"aet": "DCMTK",
"ip" : "127.0.0.1",
"port": "9999"
},
"target": {
"aet": "CONQUESTSRV1",
"ip" : "127.0.0.1",
"port": "5678"
},
"sourcePath": "./input" // Directory with DICOM files to be send
}
), (result) => {
try {
console.log(JSON.parse(result));
}
catch {
console.log(result);
}
});
```

# Find-SCU
```
dimse.findScu(JSON.stringify(
Expand Down
2 changes: 1 addition & 1 deletion dcmimage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ project(dcmimage)
include_directories("${dcmimage_SOURCE_DIR}/include" "${ofstd_SOURCE_DIR}/include" "${oflog_SOURCE_DIR}/include" "${dcmdata_SOURCE_DIR}/include" "${dcmimgle_SOURCE_DIR}/include" ${ZLIB_INCDIR} ${LIBTIFF_INCDIR} ${LIBPNG_INCDIR})

# recurse into subdirectories
foreach(SUBDIR libsrc apps include)
foreach(SUBDIR libsrc include)
add_subdirectory(${SUBDIR})
endforeach()
2 changes: 1 addition & 1 deletion dcmimgle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ project(dcmimgle)
include_directories("${dcmimgle_SOURCE_DIR}/include" "${ofstd_SOURCE_DIR}/include" "${oflog_SOURCE_DIR}/include" "${dcmdata_SOURCE_DIR}/include" ${ZLIB_INCDIR})

# recurse into subdirectories
foreach(SUBDIR libsrc apps include data)
foreach(SUBDIR libsrc include data)
add_subdirectory(${SUBDIR})
endforeach()
2 changes: 1 addition & 1 deletion dcmjpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
project(dcmjpeg)

# recurse into subdirectories
foreach(SUBDIR libsrc libijg8 libijg12 libijg16 apps include)
foreach(SUBDIR libsrc libijg8 libijg12 libijg16 include)
add_subdirectory(${SUBDIR})
endforeach()
2 changes: 1 addition & 1 deletion dcmjpls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
project(dcmjpls)

# recurse into subdirectories
foreach(SUBDIR libsrc libcharls apps include)
foreach(SUBDIR libsrc libcharls include)
add_subdirectory(${SUBDIR})
endforeach()
28 changes: 28 additions & 0 deletions examples/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const addon = require('../index');

addon.storeScu(JSON.stringify(
{
"source": {
"aet": "IMEBRA",
"ip" : "127.0.0.1",
"port": "9999"
},
"target": {
"aet": "CONQUESTSRV1",
"ip" : "127.0.0.1",
"port": "5678"
},
"sourcePath": "./examples/dicom",
"verbose": true
}
), (result) => {
if (result && result.length > 0) {
try
{
console.log(JSON.parse(result));
}
catch (e) {
console.log(e, result);
}
}
});
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"name": "dicom-dimse-native",
"version": "1.0.9",
"version": "1.1.0",
"description": "native addon using DCMTK dicom toolkit",
"main": "index.js",
"scripts": {
"install": "npx prebuild-install -r napi || npx cmake-js compile",
"example:echo": "node ./examples/echo.js",
"example:find": "node ./examples/find.js",
"example:get": "node ./examples/get.js",
"example:move": "node ./examples/move.js",
"example:store": "node ./examples/store.js",
"test": "mocha"
},
"keywords": [
Expand All @@ -15,7 +20,9 @@
"DICOM-DIMSE-NATIVE",
"DCMTK",
"NETWORK",
"DICOMJS"
"DICOMJS",
"SCU",
"SCP"
],
"author": "Michael Knopke",
"license": "ISC",
Expand Down
12 changes: 12 additions & 0 deletions src/Addon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "FindAsyncWorker.h"
#include "GetAsyncWorker.h"
#include "MoveAsyncWorker.h"
#include "StoreAsyncWorker.h"
#include "ServerAsyncWorker.h"

using namespace Napi;
Expand Down Expand Up @@ -44,6 +45,15 @@ Value DoMove(const CallbackInfo& info) {
return info.Env().Undefined();
}

Value DoStore(const CallbackInfo& info) {
std::string input = info[0].As<String>().Utf8Value();
Function cb = info[1].As<Function>();

auto worker = new StoreAsyncWorker(input, cb);
worker->Queue();
return info.Env().Undefined();
}

Value StartScp(const CallbackInfo& info) {
std::string input = info[0].As<String>().Utf8Value();
Function cb = info[1].As<Function>();
Expand All @@ -63,6 +73,8 @@ Object Init(Env env, Object exports) {
Function::New(env, DoGet));
exports.Set(String::New(env, "moveScu"),
Function::New(env, DoMove));
exports.Set(String::New(env, "storeScu"),
Function::New(env, DoStore));
exports.Set(String::New(env, "startScp"),
Function::New(env, StartScp));
return exports;
Expand Down
2 changes: 2 additions & 0 deletions src/GetAsyncWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using json = nlohmann::json;
#include "dcmtk/dcmdata/dcpath.h" /* for DcmPathProcessor */
#include "dcmtk/dcmdata/dcostrmz.h" /* for dcmZlibCompressionLevel */


#ifdef WITH_ZLIB
#include <zlib.h>
#endif
Expand Down Expand Up @@ -128,6 +129,7 @@ namespace

GetAsyncWorker::GetAsyncWorker(std::string data, Function &callback) : BaseAsyncWorker(data, callback)
{
ns::registerCodecs();
}

void GetAsyncWorker::Execute(const ExecutionProgress &progress)
Expand Down
1 change: 1 addition & 0 deletions src/ServerAsyncWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ OFCondition acceptAssociation(T_ASC_Network *net, DcmAssociationConfiguration &a

ServerAsyncWorker::ServerAsyncWorker(std::string data, Function &callback) : BaseAsyncWorker(data, callback)
{
ns::registerCodecs();
}

void ServerAsyncWorker::Execute(const ExecutionProgress &progress)
Expand Down
Loading

0 comments on commit 7f8a9eb

Please sign in to comment.