Beispiel #1
0
        /// <summary>
        /// Constructor.
        ///
        /// Use this constructor to create a new presentation context instance that is to be used in an A-ASSOCIATE-AC.
        /// </summary>
        /// <param name="abstractSyntax">The abstract syntax.</param>
        /// <param name="result">The result.</param>
        /// <param name="transferSyntax">The transfer syntax. May be empty when result is unequal to 0.</param>
        public PresentationContext(String abstractSyntax, int result, String transferSyntax)
        {
            //
            // Create the encapsulated DvtkData instance.
            //

            this.dvtkDataAcceptedPresentationContext = new DvtkData.Dul.AcceptedPresentationContext();

            this.dvtkDataAcceptedPresentationContext.AbstractSyntax = new DvtkData.Dul.AbstractSyntax(abstractSyntax);
            this.dvtkDataAcceptedPresentationContext.Result         = (Byte)result;
            this.dvtkDataAcceptedPresentationContext.TransferSyntax = new DvtkData.Dul.TransferSyntax(transferSyntax);
        }
Beispiel #2
0
        // TODO!!!: split up in three different methods and add code comments.
        public AssociateAc SendAssociateAc(params Object[] parameters)
        {
            // Start Interface logging.
            // InterfaceLogging.Start(this, parameters);

            AssociateAc associateAc = new AssociateAc(new DvtkData.Dul.A_ASSOCIATE_AC());

            associateAc.DvtkDataAssociateAc.CallingAETitle = DvtkScriptSession.SutSystemSettings.AeTitle;
            associateAc.DvtkDataAssociateAc.CalledAETitle = DvtkScriptSession.DvtSystemSettings.AeTitle;
            associateAc.DvtkDataAssociateAc.UserInformation.MaximumLength.MaximumLengthReceived = DvtkScriptSession.DvtSystemSettings.MaximumLengthReceived;
            associateAc.DvtkDataAssociateAc.UserInformation.ImplementationClassUid.UID = DvtkScriptSession.DvtSystemSettings.ImplementationClassUid;

            if (!(parameters[0] is PresentationContext))
            {
                if (this.lastAssociateRq == null)
                {
                    DvtkHighLevelInterfaceException.Throw("No associate request received.");
                }
                else
                {
                    SetAcceptedPresentationContexts(this.lastAssociateRq, associateAc, parameters);
                }
            }
            else
            {
                // Parse all parameters of this method.
                foreach(Object parameter in parameters)
                {
                    PresentationContext presentationContext = parameter as PresentationContext;

                    // If parameter is of type PresentationContext...
                    if (presentationContext != null)
                    {
                        // If the presentation context can be interpreted as a PC for an A_ASSOCIATE_AC...
                        if (presentationContext.InterpretAsPcForAssociateAc())
                        {
                            DvtkData.Dul.AcceptedPresentationContext acceptedPresentationContext = new DvtkData.Dul.AcceptedPresentationContext();

                            acceptedPresentationContext.AbstractSyntax = new DvtkData.Dul.AbstractSyntax(presentationContext.SopClass);
                            acceptedPresentationContext.TransferSyntax = new DvtkData.Dul.TransferSyntax(presentationContext.TransferSyntaxes[0] as String);
                            acceptedPresentationContext.Result = presentationContext.Result;

                            associateAc.DvtkDataAssociateAc.AddPresentationContexts(acceptedPresentationContext);
                        }
                        else
                        {
                            DvtkHighLevelInterfaceException.Throw("Error while interpreting parameters for PresentationContext");
                        }
                    }
                    else
                    {
                        DvtkHighLevelInterfaceException.Throw("Not all arguments could be used");
                    }
                }
            }

            Dvtk.Sessions.SendReturnCode sendReturnCode = DvtkScriptSession.Send(associateAc.DvtkDataAssociateAc);

            if (sendReturnCode != Dvtk.Sessions.SendReturnCode.Success)
            {
                DvtkHighLevelInterfaceException.Throw("Error sending associate accept (" + sendReturnCode.ToString() + ")");
            }
            else
            {
                associateAc.IsSend = true;
                ThreadManager.DataWarehouse.AddMessage(this, associateAc);
            }

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

            return(associateAc);
        }
Beispiel #3
0
        private void SetAcceptedPresentationContexts(AssociateRq associateRq, AssociateAc associateAc, params Object[] parameters)
        {
            TransferSyntaxes transferSyntaxes = null;
            SopClasses sopClasses = null;

            if (parameters.Length == 1)
            {
                transferSyntaxes = parameters[0] as TransferSyntaxes;

                if (transferSyntaxes == null)
                {
                    DvtkHighLevelInterfaceException.Throw("Error while interpreting parameters.");
                }
            }
            else if (parameters.Length == 2)
            {
                transferSyntaxes = parameters[0] as TransferSyntaxes;

                if (transferSyntaxes == null)
                {
                    sopClasses = parameters[0] as SopClasses;

                    if (sopClasses == null)
                    {
                        DvtkHighLevelInterfaceException.Throw("Error while interpreting parameters.");
                    }
                    else
                    {
                        transferSyntaxes = parameters[1] as TransferSyntaxes;

                        if (transferSyntaxes == null)
                        {
                            DvtkHighLevelInterfaceException.Throw("Error while interpreting parameters.");
                        }
                    }
                }
                else
                {
                    sopClasses = parameters[1] as SopClasses;

                    if (sopClasses == null)
                    {
                        DvtkHighLevelInterfaceException.Throw("Error while interpreting parameters.");
                    }
                }
            }
            else
            {
                DvtkHighLevelInterfaceException.Throw("Error while interpreting parameters.");
            }

            foreach(DvtkData.Dul.RequestedPresentationContext dvtkDataRequestedPresentationContext in associateRq.DvtkDataAssociateRq.PresentationContexts)
            {
                String sopClassToAccept = null;
                String transferSyntaxToAccept = null;

                if (sopClasses == null)
                {
                    sopClassToAccept = dvtkDataRequestedPresentationContext.AbstractSyntax.UID;
                }
                else
                {
                    foreach(String acceptedSopClass in sopClasses.list)
                    {
                        if (acceptedSopClass == dvtkDataRequestedPresentationContext.AbstractSyntax.UID)
                        {
                            sopClassToAccept = dvtkDataRequestedPresentationContext.AbstractSyntax.UID;
                            break;
                        }
                    }
                }

                if (sopClassToAccept != null)
                {
                    foreach(String acceptedTransferSyntax in transferSyntaxes.list)
                    {
                        foreach(DvtkData.Dul.TransferSyntax requestedDvtkDataTransferSyntax in dvtkDataRequestedPresentationContext.TransferSyntaxes)
                        {
                            if (acceptedTransferSyntax == requestedDvtkDataTransferSyntax.UID)
                            {
                                transferSyntaxToAccept = requestedDvtkDataTransferSyntax.UID;
                                break;
                            }
                        }

                        if (transferSyntaxToAccept != null)
                        {
                            break;
                        }
                    }

                    if (transferSyntaxToAccept != null)
                    {
                        DvtkData.Dul.AcceptedPresentationContext dvtkDataAcceptedPresentationContext = new DvtkData.Dul.AcceptedPresentationContext();

                        dvtkDataAcceptedPresentationContext.AbstractSyntax = new DvtkData.Dul.AbstractSyntax(sopClassToAccept);
                        dvtkDataAcceptedPresentationContext.TransferSyntax = new DvtkData.Dul.TransferSyntax(transferSyntaxToAccept);
                        dvtkDataAcceptedPresentationContext.Result = 0;

                        associateAc.DvtkDataAssociateAc.AddPresentationContexts(dvtkDataAcceptedPresentationContext);
                    }
                }
            }
        }
Beispiel #4
0
 /// <summary>
 /// Constructor.
 ///
 /// Use this constructor to encapsulate an existing DvtkData AcceptedPresentationContext instance.
 /// </summary>
 /// <param name="dvtkDataAcceptedPresentationContext">The DvtkData AcceptedPresentationContext instance to encapsulate.</param>
 internal PresentationContext(DvtkData.Dul.AcceptedPresentationContext dvtkDataAcceptedPresentationContext)
 {
     this.dvtkDataAcceptedPresentationContext = dvtkDataAcceptedPresentationContext;
 }