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
INetworkStreamNetwork stream.
fallbackEncoding
EncodingFallback encoding.
logger
ILoggerLogger
dependencies
DicomServiceDependenciesThe dependencies of this DICOM service
Fields
_dimseStream
protected Stream _dimseStream
Field Value
_dimseStreamFile
protected IFileReference _dimseStreamFile
Field Value
_isDisconnectedFlag
protected readonly TaskCompletionSource<bool> _isDisconnectedFlag
Field Value
Properties
Association
Gets the DICOM association.
public DicomAssociation Association { get; }
Property Value
CanStillProcessPDataTF
Gets whether or not the connection can still process P-DATA-TF
public bool CanStillProcessPDataTF { get; }
Property Value
DoHandlePDUBytes
Gets or sets an event handler to handle unsupported PDU bytes.
public PDUBytesHandler DoHandlePDUBytes { get; set; }
Property Value
IsConnected
Gets whether or not the service is connected.
public bool IsConnected { get; }
Property Value
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
IsSendQueueEmpty
Gets whether or not both the message queue and the pending queue is empty.
public bool IsSendQueueEmpty { get; }
Property Value
Logger
Gets or sets the logger.
public ILogger Logger { get; set; }
Property Value
MaximumPDUsInQueue
Gets or sets the maximum number of PDUs in queue.
public int MaximumPDUsInQueue { get; set; }
Property Value
Options
Gets or sets the DICOM service options.
public DicomServiceOptions Options { get; set; }
Property Value
UserState
Gets or sets a user state associated with the service.
public object UserState { get; set; }
Property Value
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
DicomFileA 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
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
DicomAbortSourceAbort source.
reason
DicomAbortReasonAbort reason.
Returns
SendAssociationAcceptAsync(DicomAssociation)
Send association accept response.
protected Task SendAssociationAcceptAsync(DicomAssociation association)
Parameters
association
DicomAssociationDICOM association.
Returns
SendAssociationRejectAsync(DicomRejectResult, DicomRejectSource, DicomRejectReason)
Send association reject response.
protected Task SendAssociationRejectAsync(DicomRejectResult result, DicomRejectSource source, DicomRejectReason reason)
Parameters
result
DicomRejectResultRejection result.
source
DicomRejectSourceRejection source.
reason
DicomRejectReasonRejection reason.
Returns
SendAssociationReleaseRequestAsync()
Send association release request.
protected Task SendAssociationReleaseRequestAsync()
Returns
SendAssociationReleaseResponseAsync()
Send association release response.
protected Task SendAssociationReleaseResponseAsync()
Returns
SendAssociationRequestAsync(DicomAssociation)
Send association request.
protected Task SendAssociationRequestAsync(DicomAssociation association)
Parameters
association
DicomAssociationDICOM association.
Returns
SendPDUAsync(PDU)
Asynchronously send single PDU.
protected Task SendPDUAsync(PDU pdu)
Parameters
pdu
PDUPDU to send.
Returns
- Task
Awaitable task.
SendRequestAsync(DicomRequest)
Send request from service.
public virtual Task SendRequestAsync(DicomRequest request)
Parameters
request
DicomRequestRequest to send.
Returns
SendResponseAsync(DicomResponse)
Send response from service.
protected Task SendResponseAsync(DicomResponse response)
Parameters
response
DicomResponseResponse to send.