Class DicomService
Base class for DICOM network services.
Inherited Members
Namespace: FellowOakDicom.Network
Assembly: fo-dicom.core.dll
Syntax
public abstract class DicomService : IDicomServiceRunner, IDisposable
Constructors
DicomService(INetworkStream, Encoding, ILogger, DicomServiceDependencies)
Initializes a new instance of the DicomService class.
Declaration
protected DicomService(INetworkStream stream, Encoding fallbackEncoding, ILogger logger, DicomServiceDependencies dependencies)
Parameters
Type | Name | Description |
---|---|---|
INetworkStream | stream | Network stream. |
System.Text.Encoding | fallbackEncoding | Fallback encoding. |
Microsoft.Extensions.Logging.ILogger | logger | Logger |
DicomServiceDependencies | dependencies | The dependencies of this DICOM service |
Fields
_dimseStream
Declaration
protected Stream _dimseStream
Field Value
Type | Description |
---|---|
System.IO.Stream |
_dimseStreamFile
Declaration
protected IFileReference _dimseStreamFile
Field Value
Type | Description |
---|---|
IFileReference |
_isDisconnectedFlag
Declaration
protected readonly TaskCompletionSource<bool> _isDisconnectedFlag
Field Value
Type | Description |
---|---|
System.Threading.Tasks.TaskCompletionSource<System.Boolean> |
Properties
Association
Gets the DICOM association.
Declaration
public DicomAssociation Association { get; }
Property Value
Type | Description |
---|---|
DicomAssociation |
CanStillProcessPDataTF
Gets whether or not the connection can still process P-DATA-TF
Declaration
public bool CanStillProcessPDataTF { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
DoHandlePDUBytes
Gets or sets an event handler to handle unsupported PDU bytes.
Declaration
public PDUBytesHandler DoHandlePDUBytes { get; set; }
Property Value
Type | Description |
---|---|
PDUBytesHandler |
IsConnected
Gets whether or not the service is connected.
Declaration
public bool IsConnected { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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.
Declaration
public bool IsSendNextMessageRequired { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsSendQueueEmpty
Gets whether or not both the message queue and the pending queue is empty.
Declaration
public bool IsSendQueueEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Logger
Gets or sets the logger.
Declaration
public ILogger Logger { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Extensions.Logging.ILogger |
MaximumPDUsInQueue
Gets or sets the maximum number of PDUs in queue.
Declaration
public int MaximumPDUsInQueue { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Options
Gets or sets the DICOM service options.
Declaration
public DicomServiceOptions Options { get; set; }
Property Value
Type | Description |
---|---|
DicomServiceOptions |
UserState
Gets or sets a user state associated with the service.
Declaration
public object UserState { get; set; }
Property Value
Type | Description |
---|---|
System.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.
Declaration
protected virtual void CreateCStoreReceiveStream(DicomFile file)
Parameters
Type | Name | Description |
---|---|---|
DicomFile | file | A DicomFile with FileMetaInfo populated. |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Finalize()
The finalizer will be called when this instance is not disposed properly.
Declaration
protected void Finalize()
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.
Declaration
protected virtual DicomFile GetCStoreDicomFile()
Returns
Type | Description |
---|---|
DicomFile | The DicomFile or null if the stream is not seekable. |
OnSendQueueEmptyAsync()
Action to perform when send queue is empty.
Declaration
protected virtual Task OnSendQueueEmptyAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
RunAsync()
Setup long-running operations that the DICOM service manages.
Declaration
public virtual Task RunAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Awaitable task maintaining the long-running operation(s). |
SendAbortAsync(DicomAbortSource, DicomAbortReason)
Send abort request.
Declaration
protected Task SendAbortAsync(DicomAbortSource source, DicomAbortReason reason)
Parameters
Type | Name | Description |
---|---|---|
DicomAbortSource | source | Abort source. |
DicomAbortReason | reason | Abort reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendAssociationAcceptAsync(DicomAssociation)
Send association accept response.
Declaration
protected Task SendAssociationAcceptAsync(DicomAssociation association)
Parameters
Type | Name | Description |
---|---|---|
DicomAssociation | association | DICOM association. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendAssociationRejectAsync(DicomRejectResult, DicomRejectSource, DicomRejectReason)
Send association reject response.
Declaration
protected Task SendAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
Parameters
Type | Name | Description |
---|---|---|
DicomRejectResult | result | Rejection result. |
DicomRejectSource | source | Rejection source. |
DicomRejectReason | reason | Rejection reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendAssociationReleaseRequestAsync()
Send association release request.
Declaration
protected Task SendAssociationReleaseRequestAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendAssociationReleaseResponseAsync()
Send association release response.
Declaration
protected Task SendAssociationReleaseResponseAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendAssociationRequestAsync(DicomAssociation)
Send association request.
Declaration
protected Task SendAssociationRequestAsync(DicomAssociation association)
Parameters
Type | Name | Description |
---|---|---|
DicomAssociation | association | DICOM association. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendPDUAsync(PDU)
Asynchronously send single PDU.
Declaration
protected Task SendPDUAsync(PDU pdu)
Parameters
Type | Name | Description |
---|---|---|
PDU | pdu | PDU to send. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Awaitable task. |
SendRequestAsync(DicomRequest)
Send request from service.
Declaration
public virtual Task SendRequestAsync(DicomRequest request)
Parameters
Type | Name | Description |
---|---|---|
DicomRequest | request | Request to send. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SendResponseAsync(DicomResponse)
Send response from service.
Declaration
protected Task SendResponseAsync(DicomResponse response)
Parameters
Type | Name | Description |
---|---|---|
DicomResponse | response | Response to send. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |