/// <summary> /// Starts the service. /// </summary> /// <returns>True/False depending if service started successfully.</returns> public bool Start() { try { if (isRunning) { return(true); } _staticAssocParameters = new ServerAssociationParameters(_aet, new IPEndPoint(IPAddress.Any, _port)); AddPresentationContexts(_staticAssocParameters); if (DicomServer.StartListening(_staticAssocParameters, delegate(DicomServer server, ServerAssociationParameters assoc) { return(new DicomSCP(assoc) { Aet = _aet, Port = _port }); })) { isRunning = true; } } catch (Exception ex) { throw ex; } return(isRunning); }
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"; } }
/// <summary> /// Start listening for associations. /// </summary> /// <returns>true on success, false on failure.</returns> public bool Start(IPAddress addr) { try { ListenAddress = addr; _assocParameters = new ServerAssociationParameters(AeTitle, new IPEndPoint(addr, ListenPort)); // Load our presentation contexts from all the extensions CreatePresentationContexts(); if (_assocParameters.GetPresentationContextIDs().Count == 0) { Platform.Log(LogLevel.Fatal, "No configured presentation contexts for AE: {0}", AeTitle); return(false); } return(DicomServer.StartListening(_assocParameters, StartAssociation)); } catch (DicomException ex) { Platform.Log(LogLevel.Fatal, ex, "Unexpected exception when starting listener on port {0)", ListenPort); return(false); } }
/// <summary> /// Listening is to commence. /// </summary> public void StartListening() { log.Info( string.Format("Listening on port {0} for AE {1}", this.Configuration.Port, this.Configuration.AETitle)); AssocParameters = new ServerAssociationParameters( this.Configuration.AETitle, new IPEndPoint(IPAddress.Any, this.Configuration.Port)); PresentationContextManager.AddPresentationContexts(AssocParameters, this.Configuration.SOPClassRules); // Kicks off into the thread pool. log.Info( string.Format("Launching into dicom server on AE {0} port {1}", AssocParameters.CalledAE, AssocParameters.LocalEndPoint.Port)); DicomServer.StartListening( AssocParameters, (server, assoc) => new StorageListener(Configuration, server, assoc) ); log.Info("Dicom server has been launched"); }
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 static void StartListening(string aeTitle, int port) { if (_started) { return; } _staticAssocParameters = new ServerAssociationParameters(aeTitle, new IPEndPoint(IPAddress.Any, port)); AddPresentationContexts(_staticAssocParameters); DicomServer.StartListening(_staticAssocParameters, (server, assoc) => new StorageScp(server, assoc)); _started = true; }
public static void StartListening(string aeTitle, IPAddress ip, int port) { if (_running) { return; } _param = new ServerAssociationParameters(aeTitle, new IPEndPoint(ip, port)); AddPresentationContexts(_param); DicomServer.StartListening(_param, (server, assoc) => new dcmServer(server, assoc)); _running = true; }
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 static void StartListening(string aeTitle, int port) { if (_started) { return; } _staticAssocParameters = new ServerAssociationParameters(aeTitle, new IPEndPoint(IPAddress.Any, port)); Platform.Log(LogLevel.Info, "MPPS Server Started"); AddPresentationContexts(_staticAssocParameters); DicomServer.StartListening(_staticAssocParameters, delegate(DicomServer server, ServerAssociationParameters assoc) { return(new MPPSScp(assoc)); }); _started = true; }
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); }
public static void StartListening(string aeTitle, int port, int bufferedQueryResponses, int maxQueryResponses) { _bufferedQueryResponses = bufferedQueryResponses; _maxQueryResponses = maxQueryResponses; if (_started) { return; } _staticAssocParameters = new ServerAssociationParameters(aeTitle, new IPEndPoint(IPAddress.Any, port)); Platform.Log(LogLevel.Info, "MWL Server Started"); AddPresentationContexts(_staticAssocParameters); DicomServer.StartListening(_staticAssocParameters, delegate(DicomServer server, ServerAssociationParameters assoc) { return(new MWLScp(assoc)); }); _started = true; }
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); }