/// <summary> /// Sends an A-ASSOCIATE-RQ. /// </summary> /// <param name="presentationContexts">One or more PresentationContext objects.</param> /// <returns>The sent A-ASSOCIATE-RQ</returns> /// <exception cref="System.Exception"> /// One or more of the supplied presentation contexts is an A_ASSOCIATE_AC presentation /// context or sending of the A-ASSOCIATE-RQ fails. /// </exception> /// <example> /// <b>VB.NET</b> /// <code> /// <include file='Doc\VisualBasicExamples.xml' path='Examples/Example[@name="IncludesDicomThreadScu"]' /> /// <include file='Doc\VisualBasicExamples.xml' path='Examples/Example[@name="DicomThreadScu"]' /> /// <include file='Doc\VisualBasicExamples.xml' path='Examples/Example[@name="Main"]' /> /// </code> /// </example> protected internal AssociateRq SendAssociateRq(params PresentationContext[] presentationContexts) { AssociateRq associateRq = null; // Create a DvtkData ASSOCIATE request and set default values. DvtkData.Dul.A_ASSOCIATE_RQ dvtkDataAssociateRq = new DvtkData.Dul.A_ASSOCIATE_RQ(); dvtkDataAssociateRq.CallingAETitle = Options.LocalAeTitle; dvtkDataAssociateRq.CalledAETitle = Options.RemoteAeTitle; dvtkDataAssociateRq.UserInformation.MaximumLength.MaximumLengthReceived = Options.LocalMaximumLength; dvtkDataAssociateRq.UserInformation.ImplementationClassUid.UID = Options.LocalImplementationClassUid; dvtkDataAssociateRq.UserInformation.ImplementationVersionName.Name = Options.LocalImplementationVersionName; // Parse all parameters. foreach (PresentationContext presentationContext in presentationContexts) { if (!presentationContext.IsForAssociateRequest) { throw new System.Exception("Error while interpreting parameters for PresentationContext"); } DvtkData.Dul.RequestedPresentationContext requestedPresentationContext = new DvtkData.Dul.RequestedPresentationContext(); requestedPresentationContext.AbstractSyntax = new DvtkData.Dul.AbstractSyntax(presentationContext.AbstractSyntax); foreach (String transferSyntax in presentationContext.TransferSyntaxes) { requestedPresentationContext.AddTransferSyntaxes(new DvtkData.Dul.TransferSyntax(transferSyntax)); } dvtkDataAssociateRq.AddPresentationContexts(requestedPresentationContext); } associateRq = new AssociateRq(dvtkDataAssociateRq); SendMessage(associateRq); hasOpenConnection = true; return (associateRq); }
/// <summary> /// Send a A-ASSOCIATE-RQ. /// </summary> /// <param name="presentationContexts">One or more PresentationContext objects.</param> /// <returns>The A-ASSOCIATE-RQ</returns> public AssociateRq SendAssociateRq(params PresentationContext[] presentationContexts) { // Start Interface logging. // InterfaceLogging.Start(this); AssociateRq associateRq = null; // Create a DvtkData ASSOCIATE request and set default values. DvtkData.Dul.A_ASSOCIATE_RQ dvtkDataAssociateRq = new DvtkData.Dul.A_ASSOCIATE_RQ(); dvtkDataAssociateRq.CallingAETitle = DvtkScriptSession.DvtSystemSettings.AeTitle; dvtkDataAssociateRq.CalledAETitle = DvtkScriptSession.SutSystemSettings.AeTitle; dvtkDataAssociateRq.UserInformation.MaximumLength.MaximumLengthReceived = Convert.ToUInt32(16384); dvtkDataAssociateRq.UserInformation.ImplementationClassUid.UID = "100.118.116.2003.1.4"; // Parse all parameters. foreach(PresentationContext presentationContext in presentationContexts) { if (!presentationContext.InterpretAsPcForAssociateRq()) { DvtkHighLevelInterfaceException.Throw("Error while interpreting parameters for PresentationContext"); } DvtkData.Dul.RequestedPresentationContext requestedPresentationContext = new DvtkData.Dul.RequestedPresentationContext(); requestedPresentationContext.AbstractSyntax = new DvtkData.Dul.AbstractSyntax(presentationContext.SopClass); foreach (String transferSyntax in presentationContext.TransferSyntaxes) { requestedPresentationContext.AddTransferSyntaxes(new DvtkData.Dul.TransferSyntax(transferSyntax)); } dvtkDataAssociateRq.AddPresentationContexts(requestedPresentationContext); } Dvtk.Sessions.SendReturnCode sendReturnCode = DvtkScriptSession.Send(dvtkDataAssociateRq); if (sendReturnCode != Dvtk.Sessions.SendReturnCode.Success) { DvtkHighLevelInterfaceException.Throw("Error sending associate request (" + sendReturnCode.ToString() + ")"); } else { associateRq = new AssociateRq(dvtkDataAssociateRq); associateRq.IsSend = true; ThreadManager.DataWarehouse.AddMessage(this, associateRq); } // End Interface logging. // InterfaceLogging.End(associateRq); return(associateRq); }