Table of Contents

Class DicomService

Namespace
FellowOakDicom.Network
Assembly
fo-dicom.core.dll

Base class for DICOM network services.

public abstract class DicomService : IDicomServiceRunner, IDisposable
Inheritance
DicomService
Implements
Derived
Inherited Members
Extension Methods

Constructors

DicomService(INetworkStream, Encoding, ILogger, DicomServiceDependencies)

Initializes a new instance of the DicomService class.

protected DicomService(INetworkStream stream, Encoding fallbackEncoding, ILogger logger, DicomServiceDependencies dependencies)

Parameters

stream INetworkStream

Network stream.

fallbackEncoding Encoding

Fallback encoding.

logger ILogger

Logger

dependencies DicomServiceDependencies

The dependencies of this DICOM service

Fields

_dimseStream

protected Stream _dimseStream

Field Value

Stream

_dimseStreamFile

protected IFileReference _dimseStreamFile

Field Value

IFileReference

_isDisconnectedFlag

protected readonly TaskCompletionSource<bool> _isDisconnectedFlag

Field Value

TaskCompletionSource<bool>

Properties

Association

Gets the DICOM association.

public DicomAssociation Association { get; }

Property Value

DicomAssociation

CanStillProcessPDataTF

Gets whether or not the connection can still process P-DATA-TF

public bool CanStillProcessPDataTF { get; }

Property Value

bool

DoHandlePDUBytes

Gets or sets an event handler to handle unsupported PDU bytes.

public PDUBytesHandler DoHandlePDUBytes { get; set; }

Property Value

PDUBytesHandler

IsConnected

Gets whether or not the service is connected.

public bool IsConnected { get; }

Property Value

bool

IsSendNextMessageRequired

Gets whether or not SendNextMessage is required, i.e. if any requests still have to be sent and there is no send loop currently running.

public bool IsSendNextMessageRequired { get; }

Property Value

bool

IsSendQueueEmpty

Gets whether or not both the message queue and the pending queue is empty.

public bool IsSendQueueEmpty { get; }

Property Value

bool

Logger

Gets or sets the logger.

public ILogger Logger { get; set; }

Property Value

ILogger

MaximumPDUsInQueue

Gets or sets the maximum number of PDUs in queue.

public int MaximumPDUsInQueue { get; set; }

Property Value

int

Options

Gets or sets the DICOM service options.

public DicomServiceOptions Options { get; set; }

Property Value

DicomServiceOptions

UserState

Gets or sets a user state associated with the service.

public object UserState { get; set; }

Property Value

object

Methods

CreateCStoreReceiveStream(DicomFile)

The purpose of this method is to return the Stream that a SopInstance received via CStoreSCP will be written to. This default implementation creates a temporary file and returns a FileStream on top of it. Child classes can override this to write to another stream and avoid the I/O associated with the temporary file if so desired. Beware that some SopInstances can be very large so using a MemoryStream() could cause out of memory situations.

protected virtual void CreateCStoreReceiveStream(DicomFile file)

Parameters

file DicomFile

A DicomFile with FileMetaInfo populated.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

~DicomService()

The finalizer will be called when this instance is not disposed properly.

protected ~DicomService()

Remarks

Failing to dispose indicates wrong usage

GetCStoreDicomFile()

The purpose of this method is to create a DicomFile for the SopInstance received via CStoreSCP to pass to the IDicomCStoreProvider.OnCStoreRequest method for processing. This default implementation will return a DicomFile if the stream created by CreateCStoreReceiveStream() is seekable or null if it is not. Child classes that override CreateCStoreReceiveStream may also want override this to return a DicomFile for unseekable streams or to do cleanup related to receiving that specific instance.

protected virtual DicomFile GetCStoreDicomFile()

Returns

DicomFile

The DicomFile or null if the stream is not seekable.

OnSendQueueEmptyAsync()

Action to perform when send queue is empty.

protected virtual Task OnSendQueueEmptyAsync()

Returns

Task

RunAsync()

Setup long-running operations that the DICOM service manages.

public virtual Task RunAsync()

Returns

Task

Awaitable task maintaining the long-running operation(s).

SendAbortAsync(DicomAbortSource, DicomAbortReason)

Send abort request.

protected Task SendAbortAsync(DicomAbortSource source, DicomAbortReason reason)

Parameters

source DicomAbortSource

Abort source.

reason DicomAbortReason

Abort reason.

Returns

Task

SendAssociationAcceptAsync(DicomAssociation)

Send association accept response.

protected Task SendAssociationAcceptAsync(DicomAssociation association)

Parameters

association DicomAssociation

DICOM association.

Returns

Task

SendAssociationRejectAsync(DicomRejectResult, DicomRejectSource, DicomRejectReason)

Send association reject response.

protected Task SendAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)

Parameters

result DicomRejectResult

Rejection result.

source DicomRejectSource

Rejection source.

reason DicomRejectReason

Rejection reason.

Returns

Task

SendAssociationReleaseRequestAsync()

Send association release request.

protected Task SendAssociationReleaseRequestAsync()

Returns

Task

SendAssociationReleaseResponseAsync()

Send association release response.

protected Task SendAssociationReleaseResponseAsync()

Returns

Task

SendAssociationRequestAsync(DicomAssociation)

Send association request.

protected Task SendAssociationRequestAsync(DicomAssociation association)

Parameters

association DicomAssociation

DICOM association.

Returns

Task

SendPDUAsync(PDU)

Asynchronously send single PDU.

protected Task SendPDUAsync(PDU pdu)

Parameters

pdu PDU

PDU to send.

Returns

Task

Awaitable task.

SendRequestAsync(DicomRequest)

Send request from service.

public virtual Task SendRequestAsync(DicomRequest request)

Parameters

request DicomRequest

Request to send.

Returns

Task

SendResponseAsync(DicomResponse)

Send response from service.

protected Task SendResponseAsync(DicomResponse response)

Parameters

response DicomResponse

Response to send.

Returns

Task