Mercurial > hg > orthanc
changeset 1808:9c2ffc4e938b worklists
configuration of the sample modality worklists plugin
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 23 Nov 2015 16:58:55 +0100 |
parents | 91216c42c6e5 |
children | 5ed8769b17f9 |
files | CMakeLists.txt Plugins/Samples/ModalityWorklists/CMakeLists.txt Plugins/Samples/ModalityWorklists/Plugin.cpp Plugins/Samples/ModalityWorklists/README Plugins/Samples/ServeFolders/README |
diffstat | 5 files changed, 152 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Mon Nov 23 15:26:42 2015 +0100 +++ b/CMakeLists.txt Mon Nov 23 16:58:55 2015 +0100 @@ -31,6 +31,7 @@ SET(ENABLE_JPEG_LOSSLESS ON CACHE BOOL "Enable JPEG-LS (Lossless) decompression") SET(ENABLE_PLUGINS ON CACHE BOOL "Enable plugins") SET(BUILD_SERVE_FOLDERS ON CACHE BOOL "Build the ServeFolders plugin") +SET(BUILD_MODALITY_WORKLISTS ON CACHE BOOL "Build the sample plugin to serve modality worklists") # Advanced parameters to fine-tune linking against system libraries SET(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp") @@ -511,6 +512,49 @@ ##################################################################### +## Build the "ModalityWorklists" plugin +##################################################################### + +if (ENABLE_PLUGINS AND BUILD_MODALITY_WORKLISTS) + execute_process( + COMMAND + ${PYTHON_EXECUTABLE} ${ORTHANC_ROOT}/Resources/WindowsResources.py + ${ORTHANC_VERSION} ModalityWorklists ModalityWorklists.dll "Sample Orthanc plugin to serve modality worklists" + ERROR_VARIABLE Failure + OUTPUT_FILE ${AUTOGENERATED_DIR}/ModalityWorklists.rc + ) + + if (Failure) + message(FATAL_ERROR "Error while computing the version information: ${Failure}") + endif() + + add_definitions(-DMODALITY_WORKLISTS_VERSION="${ORTHANC_VERSION}") + + include_directories(${CMAKE_SOURCE_DIR}/Plugins/Include) + + add_library(ModalityWorklists SHARED + ${BOOST_SOURCES} + ${JSONCPP_SOURCES} + Plugins/Samples/ModalityWorklists/Plugin.cpp + ${AUTOGENERATED_DIR}/ModalityWorklists.rc + ) + + set_target_properties( + ModalityWorklists PROPERTIES + VERSION ${ORTHANC_VERSION} + SOVERSION ${ORTHANC_VERSION} + ) + + install( + TARGETS ModalityWorklists + RUNTIME DESTINATION lib # Destination for Windows + LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux + ) +endif() + + + +##################################################################### ## Generate the documentation if Doxygen is present #####################################################################
--- a/Plugins/Samples/ModalityWorklists/CMakeLists.txt Mon Nov 23 15:26:42 2015 +0100 +++ b/Plugins/Samples/ModalityWorklists/CMakeLists.txt Mon Nov 23 16:58:55 2015 +0100 @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 2.8) -project(SampleModalityWorklists) +project(ModalityWorklists) -SET(SAMPLE_MODALITY_WORKLISTS_VERSION "0.0" CACHE STRING "Version of the plugin") +SET(MODALITY_WORKLISTS_VERSION "0.0" CACHE STRING "Version of the plugin") SET(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)") SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages") @@ -10,28 +10,27 @@ SET(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of boost") set(SAMPLES_ROOT ${CMAKE_SOURCE_DIR}/..) -include(${CMAKE_SOURCE_DIR}/../Common/OrthancPlugins.cmake) +include(${SAMPLES_ROOT}/Common/OrthancPlugins.cmake) include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake) include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake) -add_library(SampleModalityWorklists SHARED +add_library(ModalityWorklists SHARED Plugin.cpp ${JSONCPP_SOURCES} ${BOOST_SOURCES} ) -message("Setting the version of the plugin to ${SAMPLE_MODALITY_WORKLISTS_VERSION}") +message("Setting the version of the plugin to ${MODALITY_WORKLISTS_VERSION}") add_definitions( - -DSAMPLE_MODALITY_WORKLISTS_VERSION="${SAMPLE_MODALITY_WORKLISTS_VERSION}" - -DDEFAULT_WORKLISTS_FOLDER="${CMAKE_SOURCE_DIR}/WorklistsDatabase" + -DMODALITY_WORKLISTS_VERSION="${MODALITY_WORKLISTS_VERSION}" ) -set_target_properties(SampleModalityWorklists PROPERTIES - VERSION ${SAMPLE_MODALITY_WORKLISTS_VERSION} - SOVERSION ${SAMPLE_MODALITY_WORKLISTS_VERSION}) +set_target_properties(ModalityWorklists PROPERTIES + VERSION ${MODALITY_WORKLISTS_VERSION} + SOVERSION ${MODALITY_WORKLISTS_VERSION}) install( - TARGETS SampleModalityWorklists + TARGETS ModalityWorklists RUNTIME DESTINATION lib # Destination for Windows LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux )
--- a/Plugins/Samples/ModalityWorklists/Plugin.cpp Mon Nov 23 15:26:42 2015 +0100 +++ b/Plugins/Samples/ModalityWorklists/Plugin.cpp Mon Nov 23 16:58:55 2015 +0100 @@ -169,7 +169,8 @@ ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) { context_ = c; - OrthancPluginLogWarning(context_, "Storage plugin is initializing"); + OrthancPluginLogWarning(context_, "Sample worklist plugin is initializing"); + OrthancPluginSetDescription(context_, "Serve DICOM modality worklists from a folder with Orthanc."); /* Check the version of the Orthanc core */ if (OrthancPluginCheckVersion(c) == 0) @@ -187,29 +188,53 @@ Json::Value configuration; if (!ConvertToJson(configuration, OrthancPluginGetConfiguration(context_))) { - OrthancPluginLogError(context_, "Cannot access the configuration"); + OrthancPluginLogError(context_, "Cannot access the configuration of the worklist server"); return -1; } - if (configuration.isMember("WorklistsFolder")) + bool enabled = false; + + if (configuration.isMember("Worklists")) { - if (configuration["WorklistsFolder"].type() != Json::stringValue) + const Json::Value& config = configuration["Worklists"]; + if (!config.isMember("Enable") || + config["Enable"].type() != Json::booleanValue) { - OrthancPluginLogError(context_, "The configuration option \"WorklistsFolder\" must be a string"); + OrthancPluginLogError(context_, "The configuration option \"Worklists.Enable\" must contain a Boolean"); return -1; } + else + { + enabled = config["Enable"].asBool(); + if (enabled) + { + if (!config.isMember("Database") || + config["Database"].type() != Json::stringValue) + { + OrthancPluginLogError(context_, "The configuration option \"Worklists.Database\" must contain a path"); + return -1; + } - folder_ = configuration["WorklistsFolder"].asString(); + folder_ = config["Database"].asString(); + } + else + { + OrthancPluginLogWarning(context_, "Worklists server is disabled by the configuration file"); + } + } } else { - folder_ = DEFAULT_WORKLISTS_FOLDER; + OrthancPluginLogWarning(context_, "Worklists server is disabled, no suitable configuration section was provided"); } - std::string message = "The database of worklists will be read from folder: " + folder_; - OrthancPluginLogWarning(context_, message.c_str()); + if (enabled) + { + std::string message = "The database of worklists will be read from folder: " + folder_; + OrthancPluginLogWarning(context_, message.c_str()); - OrthancPluginRegisterWorklistCallback(context_, Callback); + OrthancPluginRegisterWorklistCallback(context_, Callback); + } return 0; } @@ -223,12 +248,12 @@ ORTHANC_PLUGINS_API const char* OrthancPluginGetName() { - return "sample-worklists"; + return "worklists"; } ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() { - return SAMPLE_MODALITY_WORKLISTS_VERSION; + return MODALITY_WORKLISTS_VERSION; } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Plugins/Samples/ModalityWorklists/README Mon Nov 23 16:58:55 2015 +0100 @@ -0,0 +1,60 @@ +Introduction +============ + +This sample plugin enables Orthanc to serve DICOM modality worklists +that are read from some folder. + +Whenever a C-Find SCP request is issued to Orthanc, it will read the +content of this folder to locate the worklists that match the request. +An external application can dynamically modify the content of this +folder while Orthanc is running to add/remove worklists. + +This sample mimics the behavior of the "wlmscpfs" tool from the +DCMTK package: +http://support.dcmtk.org/docs/wlmscpfs.html + + +Compilation for Linux +===================== + +# mkdir Build +# cd Build +# cmake .. +# make + + +Cross-compilation for Windows using MinGW +========================================= + +# mkdir Build +# cd Build +# cmake .. -DCMAKE_TOOLCHAIN_FILE=../../../Resources/MinGWToolchain.cmake +# make + + +Configuration +============= + +First, generate the default configuration of Orthanc: +https://orthanc.chu.ulg.ac.be/book/users/configuration.html + +Then, modify the "Plugins" option to point to the folder containing +the built plugins. Finally, create a section "ModalityWorklists" in +the configuration file to configure the worklist server. If using the +build commands above, a sample configuration would read as follows: + +{ + [...] + "Plugins" : [ + "." + ], + "Worklists" : { + "Enable": true, + "Database": "../WorklistsDatabase" + } +} + +The folder "WorklistsDatabase" contains a database of sample +worklists, that come from the DCMTK source distribution, as described +in the FAQ entry #37 of the DCMTK project: +http://forum.dcmtk.org/viewtopic.php?t=84
--- a/Plugins/Samples/ServeFolders/README Mon Nov 23 15:26:42 2015 +0100 +++ b/Plugins/Samples/ServeFolders/README Mon Nov 23 16:58:55 2015 +0100 @@ -27,7 +27,7 @@ ============= First, generate the default configuration of Orthanc: -https://code.google.com/p/orthanc/wiki/OrthancConfiguration +https://orthanc.chu.ulg.ac.be/book/users/configuration.html Then, modify the "Plugins" option to point to the folder containing the built plugins.