예제 #1
0
 /// <summary>
 /// This method is called after an A-ASSOCIATE-RJ has been received but before it
 /// (possibly) will be handled by the (zero or more) MessageHandler objects that
 /// are attached to this object.
 /// 
 /// Default, nothing is done in this method. Override if needed.
 /// </summary>
 /// <param name="associateRj">The received A-ASSOCIATE-RJ</param>
 public virtual void BeforeHandlingAssociateReject(AssociateRj associateRj)
 {
     // Do nothing.
 }
예제 #2
0
 /// <summary>
 /// Override this method to handle an A-ASSOCIATE-RJ.
 /// </summary>
 /// <param name="associateRj">The received A-ASSOCIATE-RJ.</param>
 /// <returns>Return true when this methods has handled the received A-ASSOCIATE-RJ, otherwise false.</returns>
 public virtual bool HandleAssociateReject(AssociateRj associateRj)
 {
     return false;
 }
예제 #3
0
 /// <summary>
 /// This method is called after an A-ASSOCIATE-RJ has been received and has 
 /// (possibly) been handled by the (zero or more) MessageHandler objects that
 /// are attached to this object.
 /// 
 /// Default, nothing is done in this method. Override if needed.
 /// </summary>
 /// <param name="associateRj">The received A-ASSOCIATE-RJ.</param>
 public virtual void AfterHandlingAssociateReject(AssociateRj associateRj)
 {
     // Do nothing.
 }
예제 #4
0
파일: DicomThread.cs 프로젝트: ewcasas/DVTK
        /// <summary>
        /// Receives a messages (can be a Dicom or Dul message).
        /// </summary>
        /// <param name="messageToExpect">Message to expect that is written in the results.</param>
        /// <returns>The received message.</returns>
        /// <exception cref="DicomProtocolMessageReceiveException">
        ///	Receiving of a message fails.
        /// </exception> 
        private DicomProtocolMessage ReceiveMessage(String messageToExpect)
        {
            DicomProtocolMessage receivedMessage = null;

            DvtkData.Message dvtkDataMessage = null;

            if (this.hasOpenConnection)
            {
                if (messageToExpect == "")
                {
                    WriteInformation("Receiving message...");
                }
                else
                {
                    WriteInformation("Receiving message (expecting " +  messageToExpect + ")...");
                }
            }
            else
            {
                WriteInformation(String.Format("Listening for incoming Dicom connection on port {0}...", Options.LocalPort));
            }

            Dvtk.Sessions.ReceiveReturnCode receiveReturnCode = DvtkScriptSession.Receive(out dvtkDataMessage);

            if (receiveReturnCode != Dvtk.Sessions.ReceiveReturnCode.Success)
            {
                throw new DicomProtocolMessageReceiveException("Error while trying to receive a Message. Error code " + receiveReturnCode.ToString() + ".", receiveReturnCode);
            }
            else
            {
                if (dvtkDataMessage is DvtkData.Dimse.DicomMessage)
                {
                    DicomMessage receivedDicomMessage = new DicomMessage(dvtkDataMessage as DvtkData.Dimse.DicomMessage);

                    // Apply the inbound DicomMessage filters if this is a DicomMessage.
                    foreach (InboundDicomMessageFilter inboundDicomMessageFilter in this.inboundDicomMessageFilters)
                    {
                        inboundDicomMessageFilter.Apply(receivedDicomMessage);
                    }

                    receivedMessage = receivedDicomMessage;
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_RQ)
                {
                    receivedMessage = new AssociateRq(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_RQ);
                    hasOpenConnection = true;
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_AC)
                {
                    receivedMessage = new AssociateAc(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_AC);
                    this.lastAssociateAc = receivedMessage as AssociateAc;
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_RJ)
                {
                    receivedMessage = new AssociateRj(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_RJ);
                    hasOpenConnection = false;
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_RELEASE_RQ)
                {
                    receivedMessage = new ReleaseRq(dvtkDataMessage as DvtkData.Dul.A_RELEASE_RQ);
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_RELEASE_RP)
                {
                    receivedMessage = new ReleaseRp(dvtkDataMessage as DvtkData.Dul.A_RELEASE_RP);
                    hasOpenConnection = false;
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ABORT)
                {
                    receivedMessage = new Abort(dvtkDataMessage as DvtkData.Dul.A_ABORT);
                    hasOpenConnection = false;
                }
                else
                {
                    Debug.Assert(true, "Unexpected DvtkData Message descendant type.");
                }

                WriteInformation("... " + receivedMessage.ToString() + " received.");

                // If the options AutoValidate is true, try to validate as much
                // as possible for the received message.
                if (Options.AutoValidate)
                {
                    Validate(receivedMessage);
                }

                MessageReceived(receivedMessage);

                if (receivedMessage is ReleaseRq)
                {
                    if (AssociationReleasedEvent != null)
                    {
                        AssociationReleasedEvent(this);
                    }
                }
            }

            return (receivedMessage);
        }
예제 #5
0
파일: DicomThread.cs 프로젝트: ewcasas/DVTK
        /// <summary>
        /// Sends a Dicom A_ASSOCIATE_RJ.
        /// </summary>
        /// <param name="result">The result as defined in the Dicom standard.</param>
        /// <param name="source">The source as defined in the Dicom standard.</param>
        /// <param name="reason">The reason as defined in the Dicom standard.</param>
        /// <returns>The sent A_ASSOCIATE_RJ.</returns>
        /// <exception cref="System.Exception">
        ///	Sending of the A_ASSOCIATE_RJ fails.
        /// </exception> 
        protected internal AssociateRj SendAssociateRj(Byte result, Byte source, Byte reason)
        {
            AssociateRj associateRj = new AssociateRj(new DvtkData.Dul.A_ASSOCIATE_RJ(result, source, reason));

            SendMessage(associateRj);

            return(associateRj);
        }
예제 #6
0
파일: DicomThread.cs 프로젝트: ewcasas/DVTK
        /// <summary>
        /// Sends a Dicom A_ASSOCIATE_RJ.
        /// </summary>
        /// <returns>The sent A_ASSOCIATE_RJ.</returns>
        /// <exception cref="System.Exception">
        ///	Sending of the A_ASSOCIATE_RJ fails.
        /// </exception> 
        protected internal AssociateRj SendAssociateRj()
        {
            AssociateRj associateRj = new AssociateRj(new DvtkData.Dul.A_ASSOCIATE_RJ());

            SendMessage(associateRj);

            return (associateRj);
        }
예제 #7
0
 public override void BeforeHandlingAssociateReject(AssociateRj associateRj)
 {
     this.SendingMessageEvent -= new SendingMessageEventHandler(QRScp_SendingMessageEvent);
     this.MessageReceivedEvent -= new MessageReceivedEventHandler(QRScp_MessageReceivedEvent);
     base.BeforeHandlingAssociateReject(associateRj);
 }