ACSE classes

The ACSE classes (Association Control Service Element) take care of negotiating a DICOM association and transporting DICOM messages between DICOM entities connected through the association.

PresentationContext

class PresentationContext

A presentation context defines which transfer syntaxes are supported for a specific abstract syntax.

Public Functions

PresentationContext(const std::string &abstractSyntax)

Constructor.

The SCU will act as SCU and the SCP will act as SCP when using this presentation context. To specify the roles of the SCU and the SCP use the other constructor which includes the roles parameters.

Parameters
  • abstractSyntax: the abstract syntax described by this presentation context

PresentationContext(const std::string &abstractSyntax, bool bSCURole, bool bSCPRole)

Constructor.

Parameters
  • abstractSyntax: the abstract syntax described by this presentation context
  • bSCURole: if true then the SCU will act as an SCU. The SCU and SCP can be both an SCU and an SCP for the same abstract syntax
  • bSCPRole: if true then the SCU will act as an SCP The SCU and SCP can be both an SCU and an SCP for the same abstract syntax

void addTransferSyntax(const std::string &transferSyntax)

Add a supported transfer syntax to the presentation context.

Parameters
  • transferSyntax: the transfer syntax to add

PresentationContexts

class PresentationContexts

A collection of presentation contexts.

Public Functions

void addPresentationContext(const PresentationContext &presentationContext)

Add a presentation context to the collection.

Parameters
  • presentationContext: the presentation context to add to the collection

AssociationMessage

class AssociationMessage

A message composed by one or two datasets.

When sending a message through an AssociationBase derived object then up to two dataset can be included into the message: the first dataset is be the command dataset, while the optional second one is the command’s payload.

Public Functions

AssociationMessage(const std::string &abstractSyntax)

Constructor.

Parameters
  • abstractSyntax: the abstract syntax of the message.

std::string getAbstractSyntax() const

Retrieve the message’s abstract syntax.

Return
the message’s abstract syntax

DataSet *getCommand() const

Return the command stored in the message.

Return
the command DataSet

DataSet *getPayload() const

Return the payload stored in the message.

Return
the payload DataSet

bool hasPayload() const

Return true if the message has a payload.

Return
true if the message has a payload, false otherwise

void addDataSet(const DataSet &dataSet)

Add a command DataSet to the message.

Two datasets can be transmitted at once: the first DataSet is the DICOM command, while the second optional one is the command payload.

Parameters
  • dataSet: a DataSet to add to the message

AssociationBase

class AssociationBase

The AssociationBase class.

Subclassed by imebra::AssociationSCP, imebra::AssociationSCU

Public Functions

virtual ~AssociationBase()

Destructor.

AssociationMessage *getCommand()

Read a command dataset and its payload (if any).

Throws StreamClosedError if the association has been released or aborted.

Return
an AssociationDataSet containing a command and its payload.

AssociationMessage *getResponse(std::uint16_t messageId)

Read a response dataset and its payload (if any).

Throws StreamClosedError if the association has been released or aborted.

Return
an AssociationDataSet containing a response and its payload.

void sendMessage(const AssociationMessage &messageDataSet)

Send a DICOM message to the connected peer.

Parameters
  • messageDataSet: the DICOM message to send

void release()

Releases the association.

The method blocks until the other party acknowledges the release command or until the ACSE timout expires.

void abort()

Aborts the association.

The association will be aborted as soon as possible. The other party will not acknowledge the abort command.

std::string getThisAET() const

Returns our AET.

Return
our AET

std::string getOtherAET() const

Returns the other party’s AET.

Return
the connected peer’s AET

std::string getTransferSyntax(const std::string &abstractSyntax) const

Returns the transfer syntax negotiated for a specific abstract syntax.

Throws:

Return
the negotiated transfer syntax for the specified abstract syntax
Parameters
  • abstractSyntax: the abstract syntax for which the transfer syntax is requested

AssociationSCU

class AssociationSCU : public imebra::AssociationBase

Represents the SCU part of an association.

The constructor tries to create an association with an SCP via the StreamReader and the StreamWriter passed as parameter; when communicating through the TCPStream then the same object is used as reader and writer.

Public Functions

AssociationSCU(const std::string &thisAET, const std::string &otherAET, std::uint32_t invokedOperations, std::uint32_t performedOperations, const PresentationContexts &presentationContexts, StreamReader &pInput, StreamWriter &pOutput, std::uint32_t dimseTimeoutSeconds)

Initiates an association request.

Blocks until the association has been negotiated successfully or an error occurs (an exception is thrown).

The constructor blocks until an association has been successfully negotiated or until an error happens (an exception is thrown).

Parameters
  • thisAET: the AET of the SCU
  • otherAET: the AET of the SCP with wich the association is negotiated
  • invokedOperations: maximum number of parallel operations we intend to invoke when acting as a SCU
  • performedOperations: maximum number of parallel operations we can perform when acting as a SCP
  • presentationContexts: list of proposed presentation contexts
  • pInput: input stream from which the SCP receives data. When using a TCPStream the same object can act as both input and output
  • pOutput: output stream into which the SCP writes data. When using a TCPStream the same object can act as both input and output
  • dimseTimeoutSeconds: DIMSE timeout, in seconds. 0 means infinite

Throws:

AssociationSCP

class AssociationSCP : public imebra::AssociationBase

Represents the SCP part of an association.

The constructor waits for an incoming DICOM association request (a-request-rq) and then returns once the association has been established, or throws CorruptedAcseMessageError if the SCU sends a wrong message type.

AssociationSCP lifecycle

Only create an AssociationSCP object AFTER the StreamReader and StreamWriter parameters have been successfully connected to their peer, then keep it alive and poll the data via readCommand() and readPayload() until a StreamClosedError or a CorruptedAcseMessageError are thrown.

StreamClosedError means that the association has been released or aborted.

If you call the abort() method on the AssociationSCP you should still wait for the StreamClosedError exception to be thrown by readCommand() or readPayload().

Public Functions

AssociationSCP(const std::string &thisAET, std::uint32_t invokedOperations, std::uint32_t performedOperations, const PresentationContexts &presentationContexts, StreamReader &pInput, StreamWriter &pOutput, std::uint32_t dimseTimeoutSeconds, std::uint32_t artimTimeoutSeconds)

Listens for an association request.

Blocks until the association has been negotiated successfully or an error occurs (an exception is thrown).

The constructor blocks until an association has been successfully negotiated or until an error happens (an exception is thrown).

Parameters
  • thisAET: the AET of the SCP. If empty then the SCP will accept associations for any called AET, otherwise it will reject the association when the called AET does not match this one
  • invokedOperations: maximum number of parallel operations we intend to invoke when acting as a SCU
  • performedOperations: maximum number of parallel operations we can perform when acting as a SCP
  • presentationContexts: list of accepted presentation contexts
  • pInput: input stream from which the SCP receives data. When using a TCPStream the same object can act as both input and output
  • pOutput: output stream into which the SCP writes data. When using a TCPStream the same object can act as both input and output
  • dimseTimeoutSeconds: DIMSE timeout, in seconds. 0 means infinite
  • artimTimeoutSeconds: ARTIM timeout, in seconds. Amount of time that is allowed to pass before an association request arrives

Throws: