private void _startStop_Click(object sender, EventArgs e) { if (_parms == null) { _parms = new ServerAssociationParameters("TEST", new IPEndPoint(IPAddress.Loopback, 105)); _parms.AddPresentationContext(1, SopClass.VerificationSopClass); _parms.AddTransferSyntax(1, TransferSyntax.ExplicitVrLittleEndian); _parms.AddTransferSyntax(1, TransferSyntax.ImplicitVrLittleEndian); _parms.AddPresentationContext(2, SopClass.StudyRootQueryRetrieveInformationModelMove); _parms.AddTransferSyntax(2, TransferSyntax.ExplicitVrLittleEndian); _parms.AddTransferSyntax(2, TransferSyntax.ImplicitVrLittleEndian); _parms.AddPresentationContext(3, SopClass.StudyRootQueryRetrieveInformationModelFind); _parms.AddTransferSyntax(3, TransferSyntax.ExplicitVrLittleEndian); _parms.AddTransferSyntax(3, TransferSyntax.ImplicitVrLittleEndian); DicomServer.StartListening(_parms, StartAssociation); _startStop.Text = "Stop Listening"; } else { DicomServer.StopListening(_parms); _parms = null; _startStop.Text = "Stop Listening"; } }
private static void AddPresentationContexts(ServerAssociationParameters assoc) { byte pcid = assoc.AddPresentationContext(SopClass.VerificationSopClass); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.ModalityWorklistInformationModelFind); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); }
private static void AddPresentationContexts(ServerAssociationParameters assoc) { byte pcid = assoc.AddPresentationContext(SopClass.VerificationSopClass); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.ModalityPerformedProcedureStepSopClass); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); }
public static void AddPresentationContexts(ServerAssociationParameters assoc, Configuration.SOPClassSet sops) { byte pcid = assoc.AddPresentationContext(SopClass.VerificationSopClass); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); FindMatchingSOPS(sops).ForEach( s => { pcid = assoc.AddPresentationContext(s); SetImageTransferSyntaxes(pcid, assoc); log.Info(string.Format("Allow SOP class {0}", s.Name)); } ); }
public void StorageScuMoveOriginatorTest() { int port = 2112; _serverHandlerList.Clear(); /* Setup the Server */ var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.Receive; DicomServer.StartListening(serverParameters, ServerHandlerCreator); string moveOriginatorAe = "ORIGINATOR"; ushort moveOriginatorId = 999; StorageScu scu = SetupScu(moveOriginatorAe, moveOriginatorId); IList <DicomAttributeCollection> list = SetupMRSeries(4, 2, DicomUid.GenerateUid().UID); foreach (DicomAttributeCollection collection in list) { var file = new DicomFile("test", new DicomAttributeCollection(), collection) { TransferSyntax = TransferSyntax.ExplicitVrLittleEndian, MediaStorageSopClassUid = SopClass.MrImageStorage.Uid, MediaStorageSopInstanceUid = collection[DicomTags.SopInstanceUid].ToString() }; scu.AddStorageInstance(new StorageInstance(file)); } scu.Send(); scu.Join(); Assert.AreEqual(scu.Status, ScuOperationStatus.NotRunning); var handler = CollectionUtils.FirstElement(_serverHandlerList); var serverHandler = handler as ServerHandler; Assert.NotNull(serverHandler); foreach (var message in serverHandler.MessagesReceived) { Assert.AreEqual(message.MoveOriginatorApplicationEntityTitle, moveOriginatorAe); Assert.AreEqual(message.MoveOriginatorMessageId, moveOriginatorId); } // StopListening DicomServer.StopListening(serverParameters); }
public void RejectTests() { int port = 2112; /* Setup the Server */ ServerAssociationParameters serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.AssociationReject; DicomServer.StartListening(serverParameters, ServerHandlerCreator); /* Setup the client */ ClientAssociationParameters clientParameters = new ClientAssociationParameters("AssocTestClient", "AssocTestServer", new System.Net.IPEndPoint(IPAddress.Loopback, port)); pcid = clientParameters.AddPresentationContext(SopClass.CtImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); /* Open the association */ ClientHandler handler = new ClientHandler(this, TestTypes.AssociationReject); DicomClient client = DicomClient.Connect(clientParameters, handler); handler._threadStop.WaitOne(); client.Dispose(); _serverType = TestTypes.AssociationReject; /* Setup the client */ clientParameters = new ClientAssociationParameters("AssocTestClient", "AssocTestServer", new System.Net.IPEndPoint(IPAddress.Loopback, port)); pcid = clientParameters.AddPresentationContext(SopClass.MrImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.Jpeg2000ImageCompressionLosslessOnly); /* Open the association */ ClientHandler clientHandler = new ClientHandler(this, TestTypes.AssociationReject); client = DicomClient.Connect(clientParameters, clientHandler); handler._threadStop.WaitOne(); client.Dispose(); DicomServer.StopListening(serverParameters); }
public void ScuAbortTest() { int port = 2112; /* Setup the Server */ var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.Receive; DicomServer.StartListening(serverParameters, ServerHandlerCreator); StorageScu scu = SetupScu(); IList <DicomAttributeCollection> list = SetupMRSeries(4, 2, DicomUid.GenerateUid().UID); foreach (DicomAttributeCollection collection in list) { var file = new DicomFile("test", new DicomAttributeCollection(), collection) { TransferSyntax = TransferSyntax.ExplicitVrLittleEndian, MediaStorageSopClassUid = SopClass.MrImageStorage.Uid, MediaStorageSopInstanceUid = collection[DicomTags.SopInstanceUid].ToString() }; scu.AddStorageInstance(new StorageInstance(file)); } scu.ImageStoreCompleted += delegate(object o, StorageInstance instance) { // Test abort scu.Abort(); }; scu.Send(); scu.Join(); Assert.AreEqual(scu.Status, ScuOperationStatus.NetworkError); // StopListening DicomServer.StopListening(serverParameters); }
public void ServerTest() { const int port = 2112; /* Setup the Server */ var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.SendMR; DicomServer.StartListening(serverParameters, ServerHandlerCreator); /* Setup the client */ var clientParameters = new ClientAssociationParameters("AssocTestClient", "AssocTestServer", new IPEndPoint(IPAddress.Loopback, port)); pcid = clientParameters.AddPresentationContext(SopClass.MrImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = clientParameters.AddPresentationContext(SopClass.CtImageStorage); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); clientParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); /* Open the association */ var handler = new ClientHandler(this, TestTypes.SendMR); DicomClient client = DicomClient.Connect(clientParameters, handler); handler._threadStop.WaitOne(); client.Dispose(); DicomServer.StopListening(serverParameters); }
private static void AddPresentationContexts(ServerAssociationParameters assoc) { byte pcid = assoc.AddPresentationContext(SopClass.VerificationSopClass); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.GrayscaleSoftcopyPresentationStateStorageSopClass); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.KeyObjectSelectionDocumentStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.ComprehensiveSrStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.BlendingSoftcopyPresentationStateStorageSopClass); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.ColonCadSrStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.DeformableSpatialRegistrationStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.EnhancedSrStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.BasicTextSrStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.EncapsulatedPdfStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.XRayRadiationDoseSrStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.ChestCadSrStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.EncapsulatedCdaStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.MrImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.CtImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.SecondaryCaptureImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.UltrasoundImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.UltrasoundImageStorageRetired); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.UltrasoundMultiFrameImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.UltrasoundMultiFrameImageStorageRetired); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.NuclearMedicineImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.DigitalIntraOralXRayImageStorageForPresentation); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.DigitalIntraOralXRayImageStorageForProcessing); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.DigitalMammographyXRayImageStorageForPresentation); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.DigitalMammographyXRayImageStorageForProcessing); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.DigitalXRayImageStorageForPresentation); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.DigitalXRayImageStorageForProcessing); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.ComputedRadiographyImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.OphthalmicPhotography16BitImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.OphthalmicPhotography8BitImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.VideoEndoscopicImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.VideoMicroscopicImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.VideoPhotographicImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.VlEndoscopicImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.VlMicroscopicImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.VlPhotographicImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.VlSlideCoordinatesMicroscopicImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.XRayAngiographicBiPlaneImageStorageRetired); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.XRayAngiographicImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.XRayRadiofluoroscopicImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.XRay3dAngiographicImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.XRay3dCraniofacialImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.OphthalmicTomographyImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.EnhancedCtImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.EnhancedMrColorImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.EnhancedMrImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.EnhancedPetImageStorage); SetImageTransferSyntaxes(pcid, assoc); pcid = assoc.AddPresentationContext(SopClass.BreastTomosynthesisImageStorage); SetImageTransferSyntaxes(pcid, assoc); }
/// <summary> /// Create the list of presentation contexts for the DICOM SCP. /// </summary> /// <remarks> /// The method loads the DICOM Scp plugins, and then queries them /// to construct a list of presentation contexts that are supported. /// </remarks> private void CreatePresentationContexts() { DicomScpExtensionPoint <TContext> ep = new DicomScpExtensionPoint <TContext>(); object[] scps = ep.CreateExtensions(); foreach (object obj in scps) { IDicomScp <TContext> scp = obj as IDicomScp <TContext>; scp.SetContext(_context); IList <SupportedSop> sops = scp.GetSupportedSopClasses(); foreach (SupportedSop sop in sops) { byte pcid = _assocParameters.FindAbstractSyntax(sop.SopClass); if (pcid == 0) { pcid = _assocParameters.AddPresentationContext(sop.SopClass); } // Now add all the transfer syntaxes, if necessary foreach (TransferSyntax syntax in sop.SyntaxList) { // Check if the syntax is registered already if (0 == _assocParameters.FindAbstractSyntaxWithTransferSyntax(sop.SopClass, syntax)) { _assocParameters.AddTransferSyntax(pcid, syntax); } } } } // Sort the presentation contexts, and put them in the order that we prefer them. // Favor Explicit over Implicit transfer syntaxes, lossless compression over lossy // compression, and lossless compressed over uncompressed. foreach (DicomPresContext serverContext in _assocParameters.GetPresentationContexts()) { serverContext.SortTransfers(delegate(TransferSyntax s1, TransferSyntax s2) { if (s1.Equals(s2)) { return(0); } if (s1.ExplicitVr && !s2.ExplicitVr) { return(-1); } if (!s1.ExplicitVr && s2.ExplicitVr) { return(1); } if (s1.Encapsulated && s2.Encapsulated) { if (s1.LosslessCompressed == s2.LosslessCompressed) { return(0); } if (s1.LosslessCompressed && s2.LossyCompressed) { return(-1); } return(1); } if (s1.Encapsulated) { if (s1.LossyCompressed) { return(1); } return(-1); } if (s2.Encapsulated) { if (s2.LossyCompressed) { return(-1); } return(1); } return(0); } ); } }
//进行SOP配对; private static void AddPresentationContexts(ServerAssociationParameters assoc) { byte pcid = assoc.AddPresentationContext(SopClass.VerificationSopClass); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.MrImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.CtImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.SecondaryCaptureImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.UltrasoundImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.UltrasoundImageStorageRetired); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.UltrasoundMultiFrameImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.UltrasoundMultiFrameImageStorageRetired); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.NuclearMedicineImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.DigitalIntraOralXRayImageStorageForPresentation); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.DigitalIntraOralXRayImageStorageForProcessing); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.DigitalMammographyXRayImageStorageForPresentation); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.DigitalMammographyXRayImageStorageForProcessing); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.DigitalXRayImageStorageForPresentation); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.DigitalXRayImageStorageForProcessing); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.ComputedRadiographyImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.GrayscaleSoftcopyPresentationStateStorageSopClass); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.KeyObjectSelectionDocumentStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.OphthalmicPhotography16BitImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.OphthalmicPhotography8BitImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.VideoEndoscopicImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.VideoMicroscopicImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.VideoPhotographicImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.VlEndoscopicImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.VlMicroscopicImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.VlPhotographicImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.VlSlideCoordinatesMicroscopicImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.XRayAngiographicBiPlaneImageStorageRetired); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.XRayAngiographicImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.XRayRadiofluoroscopicImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.XRayRadiationDoseSrStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.ChestCadSrStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.XRay3dAngiographicImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.XRay3dCraniofacialImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.EncapsulatedCdaStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.OphthalmicTomographyImageStorage); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); #region 增加的FIND的SOP pcid = assoc.AddPresentationContext(SopClass.StudyRootQueryRetrieveInformationModelFind); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.PatientRootQueryRetrieveInformationModelFind); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.PatientRootQueryRetrieveInformationModelMove); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); pcid = assoc.AddPresentationContext(SopClass.StudyRootQueryRetrieveInformationModelMove); assoc.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); assoc.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); #endregion }
public void StorageScuFromDisk() { int port = 2112; _serverHandlerList.Clear(); /* Setup the Server */ var serverParameters = new ServerAssociationParameters("AssocTestServer", new IPEndPoint(IPAddress.Any, port)); byte pcid = serverParameters.AddPresentationContext(SopClass.MrImageStorage); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrLittleEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ExplicitVrBigEndian); serverParameters.AddTransferSyntax(pcid, TransferSyntax.ImplicitVrLittleEndian); _serverType = TestTypes.Receive; DicomServer.StartListening(serverParameters, ServerHandlerCreator); StorageScu scu = SetupScu(); IList <DicomAttributeCollection> list = SetupMRSeries(4, 2, DicomUid.GenerateUid().UID); foreach (DicomAttributeCollection collection in list) { var file = new DicomFile("test", new DicomAttributeCollection(), collection) { TransferSyntax = TransferSyntax.ExplicitVrLittleEndian, MediaStorageSopClassUid = SopClass.MrImageStorage.Uid, MediaStorageSopInstanceUid = collection[DicomTags.SopInstanceUid].ToString() }; string instancePath = file.MediaStorageSopInstanceUid + ".dcm"; file.Save(instancePath); var instance = new StorageInstance(instancePath) { SopClass = file.SopClass, TransferSyntax = file.TransferSyntax, SopInstanceUid = file.MediaStorageSopClassUid, PatientId = file.DataSet[DicomTags.PatientId].GetString(0, string.Empty), PatientsName = file.DataSet[DicomTags.PatientsName].GetString(0, string.Empty), StudyInstanceUid = file.DataSet[DicomTags.StudyInstanceUid].GetString(0, string.Empty) }; scu.AddStorageInstance(instance); } scu.Send(); scu.Join(); Assert.AreEqual(scu.Status, ScuOperationStatus.NotRunning); var handler = CollectionUtils.FirstElement(_serverHandlerList); var serverHandler = handler as ServerHandler; Assert.NotNull(serverHandler); foreach (var message in serverHandler.MessagesReceived) { foreach (var file in list) { if (message.AffectedSopInstanceUid.Equals(file[DicomTags.SopInstanceUid].ToString())) { Assert.IsTrue(message.DataSet.Equals(file)); } } } // StopListening DicomServer.StopListening(serverParameters); }