示例#1
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;
 }
示例#2
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.
 }
示例#3
0
        /// <summary>
        /// Receive a message (can be a Dicom or Dul message).
        /// 
        /// An exception is thrown when receiving of a message fails.
        /// </summary>
        /// <returns>The received message.</returns>
        public Message ReceiveMessage()
        {
            // Start Interface logging.
            // InterfaceLogging.Start(this);

            DicomProtocolMessage receivedMessage = null;

            DvtkData.Message dvtkDataMessage = null;

            WriteInformation("Receive message...");

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

            if (receiveReturnCode != Dvtk.Sessions.ReceiveReturnCode.Success)
            {
                DvtkHighLevelInterfaceException.Throw("Error while trying to receive a Message. Error code " + receiveReturnCode.ToString() + ".");
            }
            else
            {
                if (dvtkDataMessage is DvtkData.Dimse.DicomMessage)
                {
                    receivedMessage = new DicomMessage(dvtkDataMessage as DvtkData.Dimse.DicomMessage);
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_RQ)
                {
                    lastAssociateRq = new AssociateRq(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_RQ);
                    receivedMessage = lastAssociateRq;
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_AC)
                {
                    receivedMessage = new AssociateAc(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_AC);
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_RJ)
                {
                    receivedMessage = new AssociateRj(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_RJ);
                }
                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);
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ABORT)
                {
                    receivedMessage = new Abort(dvtkDataMessage as DvtkData.Dul.A_ABORT);
                }
                else
                {
                    Debug.Assert(true, "Unexpected DvtkData Message descendant type.");
                }

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

                receivedMessage.IsReceived = true;
                ThreadManager.DataWarehouse.AddMessage(this, receivedMessage);

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

            // End Interface logging.
            // InterfaceLogging.End(receivedMessage);

            return(receivedMessage);
        }
示例#4
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.
 }