Inheritance: Dicom.Data.DcmDataset
Exemple #1
0
 protected void SendNSetResponse(byte presentationID, ushort messageIdRespondedTo, DicomUID affectedClass, DicomUID affectedInstance,
     DcmDataset dataset, DcmStatus status)
 {
     DcmCommand command = new DcmCommand();
     command.AffectedSOPClassUID = affectedClass;
     command.CommandField = DcmCommandField.NSetResponse;
     command.MessageIDBeingRespondedTo = messageIdRespondedTo;
     command.HasDataset = (dataset != null);
     command.Status = status;
     command.AffectedSOPInstanceUID = affectedInstance;
     Log.Info("{0} -> N-Set response [id: {1}; class: {2}]: {3}", LogID, messageIdRespondedTo, affectedClass.Description, status);
     SendDimse(presentationID, command, dataset);
 }
Exemple #2
0
 protected void SendNGetRequest(byte presentationID, ushort messageID, DicomUID requestedClass, DicomUID requestedInstance, DicomTag[] attributes)
 {
     DcmCommand command = new DcmCommand();
     command.RequestedSOPClassUID = requestedClass;
     command.CommandField = DcmCommandField.NGetRequest;
     command.MessageID = messageID;
     command.HasDataset = false;
     command.RequestedSOPInstanceUID = requestedInstance;
     command.AttributeIdentifierList = new DcmAttributeTag(DicomTags.AttributeIdentifierList);
     command.AttributeIdentifierList.SetValues(attributes);
     Log.Info("{0} -> N-Get request [pc: {1}; id: {2}; class: {3}]", LogID, presentationID, messageID, requestedClass.Description);
     SendDimse(presentationID, command, null);
 }
Exemple #3
0
 protected void SendNSetRequest(byte presentationID, ushort messageID, DicomUID requestedClass, DicomUID requestedInstance, DcmDataset dataset)
 {
     DcmCommand command = new DcmCommand();
     command.RequestedSOPClassUID = requestedClass;
     command.CommandField = DcmCommandField.NSetRequest;
     command.MessageID = messageID;
     command.HasDataset = (dataset != null);
     command.RequestedSOPInstanceUID = requestedInstance;
     Log.Info("{0} -> N-Set request [pc: {1}; id: {2}; class: {3}]", LogID, presentationID, messageID, requestedClass.Description);
     SendDimse(presentationID, command, dataset);
 }
Exemple #4
0
 protected void SendNActionRequest(byte presentationID, ushort messageID, DicomUID requestedClass, DicomUID requestedInstance, 
     ushort actionTypeID, DcmDataset dataset)
 {
     DcmCommand command = new DcmCommand();
     command.RequestedSOPClassUID = requestedClass;
     command.CommandField = DcmCommandField.NActionRequest;
     command.MessageID = messageID;
     command.HasDataset = (dataset != null);
     command.RequestedSOPInstanceUID = requestedInstance;
     command.ActionTypeID = actionTypeID;
     Log.Info("{0} -> N-Action request [pc: {1}; id: {2}; class: {3}; action: {4:x4}]",
         LogID, presentationID, messageID, requestedClass, actionTypeID);
     SendDimse(presentationID, command, dataset);
 }
Exemple #5
0
 protected void SendNEventReportRequest(byte presentationID, ushort messageID, DicomUID affectedClass, DicomUID affectedInstance, 
     ushort eventTypeID, DcmDataset dataset)
 {
     DcmCommand command = new DcmCommand();
     command.AffectedSOPClassUID = affectedClass;
     command.CommandField = DcmCommandField.NEventReportRequest;
     command.MessageID = messageID;
     command.HasDataset = (dataset != null);
     command.AffectedSOPInstanceUID = affectedInstance;
     command.EventTypeID = eventTypeID;
     Log.Info("{0} -> N-EventReport request [pc: {1}; id: {2}; class: {3}; event: {4:x4}]",
         LogID, presentationID, messageID, affectedClass.Description, eventTypeID);
     SendDimse(presentationID, command, dataset);
 }
Exemple #6
0
 protected virtual void OnSendDimseProgress(byte pcid, DcmCommand command, DcmDataset dataset, DcmDimseProgress progress)
 {
 }
Exemple #7
0
 protected void SendCCancelRequest(byte presentationID, ushort messageIdRespondedTo)
 {
     DcmCommand command = new DcmCommand();
     command.CommandField = DcmCommandField.CCancelRequest;
     command.MessageIDBeingRespondedTo = messageIdRespondedTo;
     command.HasDataset = false;
     Log.Info("{0} -> C-Cancel request [pc: {1}; id: {2}]", LogID, presentationID, messageIdRespondedTo);
     SendDimse(presentationID, command, null);
 }
Exemple #8
0
        private bool SendDimseStream(byte pcid, DcmCommand command, Stream datastream)
        {
            try {
                _disableTimeout = true;

                DicomTransferSyntax ts = _assoc.GetAcceptedTransferSyntax(pcid);

                DcmDimseProgress progress = new DcmDimseProgress();

                progress.EstimatedCommandLength = (int)command.CalculateWriteLength(DicomTransferSyntax.ImplicitVRLittleEndian, DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths);

                if (datastream != null)
                    progress.EstimatedDatasetLength = (int)datastream.Length - (int)datastream.Position;

                PDataTFStream pdustream = new PDataTFStream(_network, pcid, (int)_assoc.MaximumPduLength);
                pdustream.OnPduSent += delegate() {
                    progress.BytesTransfered = pdustream.BytesSent;
                    OnSendDimseProgress(pcid, command, null, progress);
                };

                lock (_socket) {
                    OnSendDimseBegin(pcid, command, null, progress);

                    DicomStreamWriter dsw = new DicomStreamWriter(pdustream);
                    dsw.Write(command, DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths);
                    dsw = null;

                    if (datastream != null) {
                        pdustream.IsCommand = false;
                        pdustream.Write(datastream);
                    }

                    // last pdu is automatically flushed when streaming
                    //pdustream.Flush(true);

                    OnSendDimse(pcid, command, null, progress);
                }

                return true;
            }
            catch (Exception e) {
            #if DEBUG
                Log.Error("{0} -> Error sending DIMSE: {1}", LogID, e.ToString());
            #else
                Log.Error("{0} -> Error sending DIMSE: {1}", LogID, e.Message);
            #endif
                OnNetworkError(e);
                return false;
            }
            finally {
                _disableTimeout = false;
            }
        }
Exemple #9
0
 protected virtual void OnReceiveDimseBegin(byte pcid, DcmCommand command, DcmDataset dataset, DcmDimseProgress progress)
 {
 }
Exemple #10
0
        private bool SendDimse(byte pcid, DcmCommand command, DcmDataset dataset)
        {
            try {
                _disableTimeout = true;

                DicomTransferSyntax ts = _assoc.GetAcceptedTransferSyntax(pcid);

                if (dataset != null && ts != dataset.InternalTransferSyntax) {
                    if (ts.IsEncapsulated || dataset.InternalTransferSyntax.IsEncapsulated)
                        throw new DicomNetworkException("Unable to transcode encapsulated transfer syntax!");
                    dataset.ChangeTransferSyntax(ts, null);
                }

                DcmDimseProgress progress = new DcmDimseProgress();

                progress.EstimatedCommandLength = (int)command.CalculateWriteLength(DicomTransferSyntax.ImplicitVRLittleEndian, DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths);

                if (dataset != null)
                    progress.EstimatedDatasetLength = (int)dataset.CalculateWriteLength(ts, DicomWriteOptions.Default);

                PDataTFStream pdustream = new PDataTFStream(_network, pcid, (int)_assoc.MaximumPduLength);
                pdustream.OnPduSent += delegate() {
                    progress.BytesTransfered = pdustream.BytesSent;
                    OnSendDimseProgress(pcid, command, dataset, progress);
                };

                lock (_socket) {
                    OnSendDimseBegin(pcid, command, dataset, progress);

                    DicomStreamWriter dsw = new DicomStreamWriter(pdustream);
                    dsw.Write(command, DicomWriteOptions.Default | DicomWriteOptions.CalculateGroupLengths);

                    if (dataset != null) {
                        pdustream.IsCommand = false;
                        dsw.Write(dataset, DicomWriteOptions.Default);
                    }

                    // flush last pdu
                    pdustream.Flush(true);

                    OnSendDimse(pcid, command, dataset, progress);
                }

                return true;
            }
            catch (Exception e) {
            #if DEBUG
                Log.Error("{0} -> Error sending DIMSE: {1}", LogID, e.ToString());
            #else
                Log.Error("{0} -> Error sending DIMSE: {1}", LogID, e.Message);
            #endif
                OnNetworkError(e);
                return false;
            }
            finally {
                _disableTimeout = false;
            }
        }
Exemple #11
0
 private DcmCommand CreateResponse(ushort messageIdRespondedTo, DcmCommandField commandField, DicomUID affectedClass, DcmStatus status, bool hasDataset)
 {
     DcmCommand command = new DcmCommand();
     command.AffectedSOPClassUID = affectedClass;
     command.CommandField = commandField;
     command.MessageIDBeingRespondedTo = messageIdRespondedTo;
     command.HasDataset = hasDataset;
     command.Status = status;
     if (!String.IsNullOrEmpty(status.ErrorComment))
         command.ErrorComment = status.ErrorComment;
     return command;
 }
Exemple #12
0
 private DcmCommand CreateRequest(ushort messageID, DcmCommandField commandField, DicomUID affectedClass, DcmPriority priority, bool hasDataset)
 {
     DcmCommand command = new DcmCommand();
     command.AffectedSOPClassUID = affectedClass;
     command.CommandField = commandField;
     command.MessageID = messageID;
     command.Priority = priority;
     command.HasDataset = hasDataset;
     return command;
 }
        protected override void OnReceiveDimse(byte pcid, DcmCommand command, DcmDataset dataset, DcmDimseProgress progress)
        {
            if (command.CommandField == DcmCommandField.CStoreRequest)
            {
                IsReceiveConnection = true;
                SaveDimseToFile(dataset);
            }

            base.OnReceiveDimse(pcid, command, dataset, progress);
        }
		private DcmCommand CreateResponse(ushort messageIdRespondedTo, DcmCommandField commandField, DicomUID affectedClass, DcmStatus status, bool hasDataset) {
			DcmCommand command = new DcmCommand();
			command.AffectedSOPClassUID = affectedClass;
			command.CommandField = commandField;
			command.MessageIDBeingRespondedTo = messageIdRespondedTo;
			command.HasDataset = hasDataset;
			command.Status = status;
			return command;
		}