![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Dicom/DicomPacsCommunication.h>
Class facilitating the communication with DICOM PACS servers. More...
Class facilitating the communication with DICOM PACS servers.
DicomPacsCommunication automates issuing C-FIND and C-MOVE commands as well as receiving C-STORE commands. Receiving data from PACS servers is easily customized by attaching a callback function to the request.
This class also provides lean wrappers around asynchronous (non-blocking) requests. DicomPacsCommunication protects all C-MOVE requests to the PACS server by a mutex and thereby ensures that only a single thread is issuing C-MOVE requests at a time. However, outgoing async requests (i.e. C-ECHO, C-FIND and C-STORE) will be sent concurrently since every modern PACS instance should support this. If your particular instance does not, please keep to the synchronous methods. The scheduling of asynchronous requests is based on std::async and thus relies on the OS thread scheduling.
DicomPacsCommunication can be considered as thread-safe in the following way:
Classes | |
struct | AsyncRequestInfo |
Structure wrapping the return value of an asynchronous PACS request. More... | |
Public Types | |
enum | RetrieveInformationModel { PatientRootRetrieveInformationModel , StudyRootRetrieveInformationModel , ModalityWorklistInformationModel } |
Enumeration of Standard Query/Retrieve Information Models. More... | |
![]() | |
using | ErrorCallback = std::function<void(const Error&)> |
Alias for a function to call for each error recorded. | |
Public Member Functions | |
DicomPacsCommunication (DicomPacsConfiguration configuration) | |
Creates a new PCAS communication instance connecting to the server defined in the given configuration. | |
const DicomPacsConfiguration & | connectionConfiguration () const |
Returns the connection configuration to use when communicating with the PACS server. | |
bool | sendEchoRequest () |
Connects to the configured PACS and sends a C-ECHO message in order to test the association. | |
void | sendFindRequest (RetrieveInformationModel queryModel, DcmDataset &request, std::function< void(std::unique_ptr< DcmDataset >)> responseItemCallback, std::atomic< bool > *abortFlag=nullptr) |
Synchronously sends a C-FIND request to the currently connected PACS server. | |
AsyncRequestInfo | sendFindRequestAsync (RetrieveInformationModel queryModel, DcmDataset &request, std::function< void(std::unique_ptr< DcmDataset >)> responseItemCallback, std::function< void(bool)> finishedCallback) |
Asynchronously sends a C-FIND request to the currently connected PACS server. | |
void | sendMoveRequest (RetrieveInformationModel queryModel, DcmDataset &request, std::function< void(std::unique_ptr< DcmDataset >)> responseItemCallback) |
Synchronously sends a C-MOVE request to the currently connected PACS server. | |
AsyncRequestInfo | sendMoveRequestAsync (RetrieveInformationModel queryModel, DcmDataset &request, std::function< void(std::unique_ptr< DcmDataset >)> responseItemCallback, std::function< void(bool)> finishedCallback) |
Asynchronously sends a C-MOVE request to the currently connected PACS server. | |
bool | sendStoreRequest (const std::vector< DcmDataset * > &datasets, int transferSyntax, std::atomic< bool > *abortFlag=nullptr) |
Synchronously sends a C-STORE request to the currently connected PACS server. | |
void | abortAsyncRequests () |
Aborts all async request currently in flight. | |
void | waitForAsyncRequests () |
Blocks until all async requests that are currently in flight have been completed. | |
![]() | |
virtual void * | registerErrorHandler (ErrorCallback handler) |
Registers a new handler callback function. | |
virtual void | unregisterErrorHandler (void *handler) |
Removes a previously registered handler again. | |
void * | forwardErrors (const ErrorRecorder *otherRecorder) |
Convenient function to forward all errors registered to this recorder to another recorder. | |
virtual void | registerError (const Error &error) const |
Sends the given error to all error handler callbacks. | |
void | registerError (Error::Code code, Error::Type type, const std::string &details, TagProxy tag=TagProxy()) const |
Enumeration of Standard Query/Retrieve Information Models.
void sendFindRequest | ( | RetrieveInformationModel | queryModel, |
DcmDataset & | request, | ||
std::function< void(std::unique_ptr< DcmDataset >)> | responseItemCallback, | ||
std::atomic< bool > * | abortFlag = nullptr ) |
Synchronously sends a C-FIND request to the currently connected PACS server.
queryModel | Query/Retrieve Information Model to use for the request. |
request | Dicom object representing the request to send. |
responseItemCallback | Callback method to call for every item of the response. |
abortFlag | Flag that will abort the request at next possibility. The pointer must stay valid until the request finishes. |
AsyncRequestInfo sendFindRequestAsync | ( | RetrieveInformationModel | queryModel, |
DcmDataset & | request, | ||
std::function< void(std::unique_ptr< DcmDataset >)> | responseItemCallback, | ||
std::function< void(bool)> | finishedCallback ) |
Asynchronously sends a C-FIND request to the currently connected PACS server.
queryModel | Query/Retrieve Information Model to use for the request. |
request | Dicom object representing the request to send. |
responseItemCallback | Callback method to call for every item of the response. |
finishedCallback | Callback method to call when the request has been completed, the bool parameter indicates the state of the abort flag. |
void sendMoveRequest | ( | RetrieveInformationModel | queryModel, |
DcmDataset & | request, | ||
std::function< void(std::unique_ptr< DcmDataset >)> | responseItemCallback ) |
Synchronously sends a C-MOVE request to the currently connected PACS server.
queryModel | Query/Retrieve Information Model to use for the request. |
request | Dicom object representing the request to send. |
responseItemCallback | Callback method to call for every item of the response. |
AsyncRequestInfo sendMoveRequestAsync | ( | RetrieveInformationModel | queryModel, |
DcmDataset & | request, | ||
std::function< void(std::unique_ptr< DcmDataset >)> | responseItemCallback, | ||
std::function< void(bool)> | finishedCallback ) |
Asynchronously sends a C-MOVE request to the currently connected PACS server.
queryModel | Query/Retrieve Information Model to use for the request. |
request | Dicom object representing the request to send. |
responseItemCallback | Callback method to call for every item of the response. |
finishedCallback | Callback method to call when the request has been completed, the bool parameter indicates the state of the abort flag. |
bool sendStoreRequest | ( | const std::vector< DcmDataset * > & | datasets, |
int | transferSyntax, | ||
std::atomic< bool > * | abortFlag = nullptr ) |
Synchronously sends a C-STORE request to the currently connected PACS server.
All datasets are generally send as a single association except if the datasets use over 128 different SOP class UIDs. If the request is aborted before it finishes, all datasets already sent to the PACS are not deleted!
datasets | List of DcmDatasets to send to the server. |
transferSyntax | Transfer syntax to choose for sending the data set to the PACS instance. Use values from DCMTK's E_TransferSyntax enum in dcxfer.h. |
abortFlag | Flag that will abort the request at next possibility. The pointer must stay valid until the request finishes. |
void abortAsyncRequests | ( | ) |
Aborts all async request currently in flight.
This includes scheduled move requests that have not yet been started due to another move request being active.
void waitForAsyncRequests | ( | ) |
Blocks until all async requests that are currently in flight have been completed.
This includes scheduled move requests that have not yet been started due to another move request being active.