LAUREL BRIDGE

LaurelBridge.DCFExamples.EchoSCU Namespace

DICOM Connectivity Framework V3.4
The EchoSCU example demonstrates how to use DCF to create a VerificationSCU and perform a C-Echo to a VerificationSCP.
Classes

  ClassDescription
Public classDicomSocketCreator
DICOM Socket Creator class
Public classOptions
Command line options class for parsing user options for EchoSCU.
Public classProgram
A simple echo client example that shows how to do a DICOM ping. This program should be run with a Verification SCP running on localhost listening on port 10104 by default. This class also supports TLS for processing encrypted messages which should be run with VerificationSCPExtended with corresponding TLS levels enabled. View the --help command line option to see a summary of the TLS command line options.
Public classProgramMyVerificationSCU
MyVerificationSCU extends VerificationSCU to override the CreateDicomSocket method
Remarks

Supported OS Platforms:

  • Windows - .Net Framework 4.7.2 64-bit and 32-bit
  • Windows - .Net Core 2.1 64-bit and 32-bit
  • Linux - .Net Core 2.1 64-bit

Examples

EchoSCU Sample Code
public class Program
{
    /// <summary>
    /// Main entry point for EchoSCU.
    /// </summary>
    /// <param name="args">command line arguments</param>
    [STAThread]
    public static void Main(string[] args)
    {
        Console.Title = "LaurelBridge.DCFExamples.EchoSCU";
        try
        {
            Options options;
            if (!Options.TryParse(args, out options))
            {
                throw new ArgumentException("bad command line parameters");
            }

            VerificationSCU scu = new MyVerificationSCU(options);
            scu.RequestAssociation();
            // do a DICOM ping with a 30 second timeout
            CEchoResponse response = scu.CEcho(30);
            scu.ReleaseAssociation();

            Console.WriteLine("c-Echo returned {0}", response.Status);
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception caught during execution: {0}{1}{1}Please verify the Verification SCP is up and running.", e, Environment.NewLine);
            Environment.ExitCode = 1;
        }

        if (System.Diagnostics.Debugger.IsAttached)
        {
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey();
        }
    }

    /// <summary>
    /// MyVerificationSCU extends VerificationSCU to override the CreateDicomSocket method
    /// </summary>
    public class MyVerificationSCU : VerificationSCU
    {
        private readonly Options _options;
        private readonly DicomSocketCreator _socketCreator;

        /// <summary>
        /// Constructor with command line options
        /// </summary>
        /// <param name="options">command line options</param>
        public MyVerificationSCU(Options options)
            : this(
                new AssociationInfo()
                {
                    CallingTitle = "SCU",
                    CalledPresentationAddress = options.Host + ":" + options.Port,
                    CalledTitle = "SCP"
                },
                options,
                new DicomSocketCreator()
                )
        { }

        /// <summary>
        /// Constructor with AssociationInfo, session settings, command line options and socket creator that supports unencrypted and TLS connections
        /// </summary>
        /// <param name="ainfo">association info</param>
        /// <param name="options">command line options</param>
        /// <param name="socketCreator">DICOM socket creator</param>
        public MyVerificationSCU(AssociationInfo ainfo, Options options, DicomSocketCreator socketCreator)
            : base(ainfo.CallingTitle, new DicomAddress(options.Host, options.Port, ainfo.CalledTitle))
        {
            _options = options;
            _socketCreator = socketCreator;
        }

        /// <summary>
        /// Create DICOM socket with host, port, session settings, and association info
        /// </summary>
        /// <param name="host">Host of Echo SCP</param>
        /// <param name="port">Port for Echo SCP</param>
        /// <param name="sessionSettings">DICOM session settings</param>
        /// <param name="ainfo">association info</param>
        /// <returns>new instance of a DicomSocket</returns>
        protected override DicomSocket CreateDicomSocket(string host, int port, DicomSessionSettings sessionSettings, AssociationInfo ainfo)
        {
            return _socketCreator.Create(_options, sessionSettings, ainfo);
        }
    }
}