예제 #1
0
        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";
            }
        }
예제 #2
0
 public static void StopListening(int port)
 {
     if (_started)
     {
         DicomServer.StopListening(_staticAssocParameters);
         _started = false;
     }
 }
예제 #3
0
 public static void StopListening(int port)
 {
     if (_running)
     {
         DicomServer.StopListening(_param);
         _running = false;
     }
 }
예제 #4
0
        /// <summary>
        /// Listening is complete.
        /// </summary>
        /// <param name="port"></param>
        public void StopListening(int port)
        {
            log.Info(
                string.Format("Stop Listening on port {0} for AE {1}",
                              this.Configuration.Port,
                              this.Configuration.AETitle));

            DicomServer.StopListening(AssocParameters);
        }
예제 #5
0
 public static void StopListening(int port)
 {
     if (_started)
     {
         Platform.Log(LogLevel.Info, "Stopping The MWL server...");
         DicomServer.StopListening(_staticAssocParameters);
         _started = false;
         Platform.Log(LogLevel.Info, "MWL Server Stopped.");
     }
 }
예제 #6
0
 /// <summary>
 /// Stop the association listener.
 /// </summary>
 public void Stop()
 {
     try
     {
         DicomServer.StopListening(_assocParameters);
     }
     catch (DicomException e)
     {
         Platform.Log(LogLevel.Error, e, "Unexpected exception when stopping listening on port {0}", ListenPort);
     }
 }
예제 #7
0
        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);
        }
예제 #8
0
파일: DicomScp.cs 프로젝트: 1059444127/XA
 /// <summary>
 /// Stop the association listener.
 /// </summary>
 public void Stop()
 {
     try
     {
         DicomServer.StopListening(_assocParameters);
     }
     catch (DicomException e)
     {
         LogAdapter.Logger.Error(e, "Unexpected exception when stopping listening on port {0}", ListenPort);
     }
 }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
    /// <summary>
    /// Stops the service.
    /// </summary>
    public void Stop()
    {
        try
        {
            if (isRunning)
            {
                DicomServer.StopListening(_staticAssocParameters);
            }
        }

        finally
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();

            isRunning = false;
        }
    }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }