How to perform Storage Commitment ?

851 views
Skip to first unread message

Mukul Lanke

unread,
May 14, 2014, 1:50:11 AM5/14/14
to fo-d...@googlegroups.com
Hello Everybody,

I am developing a PACS Server and now I am interfacing with the modalities. For testing my program, I am using the Modality Emulator by DVTk (http://sourceforge.net/projects/dvt/files/Modality%20Emulator/Modality%20Emulator%203.1.5/Modality%20Emulator%203.1.5.0.msi/download). 

I could implement the C-Echo, C-Find SCP, MPPS (N-Create and N-Set) SCP and C-Store SCP services. Now I am trying to implement Storage Commitment service. In this, I received the NActionRequest from the Emulator and could return the NActionResponse for the same. Now I am stuck with how to send NEventReportRequest to the Modality Emulator. Below is the code for the same (C-Store SCP class) :

( I am including the 'Storage' operation and 'Storage Commitment' operation both in a single class ) :

public class CStoreSCP : DicomService, IDicomServiceProvider, IDicomCStoreProvider, IDicomCEchoProvider, IDicomNServiceProvider
    {
        private static DicomTransferSyntax[] AcceptedTransferSyntaxes = new DicomTransferSyntax[] {
DicomTransferSyntax.ExplicitVRLittleEndian,
DicomTransferSyntax.ExplicitVRBigEndian,
DicomTransferSyntax.ImplicitVRLittleEndian
};

        private static DicomTransferSyntax[] AcceptedImageTransferSyntaxes = new DicomTransferSyntax[] {
// Lossless
DicomTransferSyntax.JPEGLSLossless,
DicomTransferSyntax.JPEG2000Lossless,
DicomTransferSyntax.JPEGProcess14SV1,
DicomTransferSyntax.JPEGProcess14,
DicomTransferSyntax.RLELossless,
// Lossy
DicomTransferSyntax.JPEGLSNearLossless,
DicomTransferSyntax.JPEG2000Lossy,
DicomTransferSyntax.JPEGProcess1,
DicomTransferSyntax.JPEGProcess2_4,

// Uncompressed
DicomTransferSyntax.ExplicitVRLittleEndian,
DicomTransferSyntax.ExplicitVRBigEndian,
DicomTransferSyntax.ImplicitVRLittleEndian
};

        public CStoreSCP(Stream stream, Logger log)
            : base(stream, log)
        {
        }

        public void OnReceiveAssociationRequest(DicomAssociation association)
        {
            if (association.CalledAE != Constants.AETitle)
            {
                SendAssociationReject(DicomRejectResult.Permanent, DicomRejectSource.ServiceUser, DicomRejectReason.CalledAENotRecognized);
                return;
            }

            foreach (var pc in association.PresentationContexts)
            {
                if (pc.AbstractSyntax == DicomUID.Verification)
                    pc.AcceptTransferSyntaxes(AcceptedTransferSyntaxes);
                else if (pc.AbstractSyntax.StorageCategory != DicomStorageCategory.None)
                    pc.AcceptTransferSyntaxes(AcceptedImageTransferSyntaxes);
            }

            SendAssociationAccept(association);
        }

        public void OnReceiveAssociationReleaseRequest()
        {
            SendAssociationReleaseResponse();
        }

        public void OnReceiveAbort(DicomAbortSource source, DicomAbortReason reason)
        {
            throw new NotImplementedException();
        }

        public void OnConnectionClosed(int errorCode)
        {
        }

        public DicomCStoreResponse OnCStoreRequest(DicomCStoreRequest request)
        {
            var studyUid = request.Dataset.Get<string>(DicomTag.StudyInstanceUID);
            var instUid = request.SOPInstanceUID.UID;

            var path = Path.GetFullPath(Program.StoragePath);
            path = Path.Combine(path, studyUid);

            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);

            path = Path.Combine(path, instUid) + ".dcm";

            request.File.Save(path);

            return new DicomCStoreResponse(request, DicomStatus.Success);
        }

        public void OnCStoreRequestException(string tempFileName, Exception e)
        {
            // let library handle logging and error response
        }

        public DicomCEchoResponse OnCEchoRequest(DicomCEchoRequest request)
        {
            return new DicomCEchoResponse(request, DicomStatus.Success);
        }

        public DicomNActionResponse OnNActionRequest(DicomNActionRequest request)
        {
            /* Just wrote this code for sending NEventReportRequest, but didn't get expected result, hence commented */
            // DicomNEventReportRequest nEventReportReq = new DicomNEventReportRequest(request.SOPClassUID, request.SOPInstanceUID, 1);
            // nEventReportReq.OnResponseReceived += new DicomNEventReportRequest.ResponseDelegate(NEventReportResponseReceivedMethod);
            // SendRequest(nEventReportReq);
   
            //code for sending NActionResponse to Modality Emulator
            DicomNActionResponse dicomNActionResp = new DicomNActionResponse(request, DicomStatus.Success);
            return dicomNActionResp;
        }

        public void NEventReportResponseReceivedMethod(DicomNEventReportRequest request, DicomNEventReportResponse response)
        {
            //just to print if NEventReportResponse object is received from the Modality to the PACS
            ConsoleLogger.Instance.Log(LogLevel.Info, response.SOPInstanceUID.ToString(), new object[] { });
        }

        public DicomNCreateResponse OnNCreateRequest(DicomNCreateRequest request)
        {
            throw new NotImplementedException();
        }

        public DicomNDeleteResponse OnNDeleteRequest(DicomNDeleteRequest request)
        {
            throw new NotImplementedException();
        }

        public DicomNEventReportResponse OnNEventReportRequest(DicomNEventReportRequest request)
        {
            throw new NotImplementedException();
        }

        public DicomNGetResponse OnNGetRequest(DicomNGetRequest request)
        {
            throw new NotImplementedException();
        }

        public DicomNSetResponse OnNSetRequest(DicomNSetRequest request)
        {
            throw new NotImplementedException();
        }
    }

And here is my Main method (program entry point) :

class Program
{
        static void Main(string[] args)
        {
            // preload dictionary to prevent timeouts
            var dict = DicomDictionary.Default;
            // start DICOM server on specified port
            var server = new DicomServer<CStoreSCP>(Constants.Port);

            //AETitle and Port are static fields in Constants class
            Console.WriteLine("C-Store SCP Server (AE = {0}) Started on localhost on Port {1}", Constants.AETitle, Constants.Port);   
           
            // end process
            Console.WriteLine("Press <return> to end...");
            Console.ReadLine();
        }
}

I would be grateful is somebody guides me in this issue.

Thank You.

--
Mukul Lanke
Reply all
Reply to author
Forward
0 new messages