コード例 #1
0
        public T GetResponse <T, U>(U request, Entity e, ref ushort msgId) where U : AbstractDIMSERequest where T : AbstractDIMSEResponse
        {
            System.DateTime lastContact = System.DateTime.Now;
            int             msWait      = 2000;

            var mr   = new ManualResetEvent(false);
            T   resp = null;
            var cr   = new Services.DIMSEService.DIMSEResponseHandler <T>((res, asc) =>
            {
                lastContact = System.DateTime.Now;
                resp        = res;
                if (res.Status != (ushort)Status.PENDING)
                {
                    mr.Set();
                }
                else
                {
                    mr.Reset();
                }
            });

            DIMSEService.Subscribe(cr);
            SendMessage(request, e);
            mr.WaitOne(msWait);
            DIMSEService.Unsubscribe(cr);
            msgId += 2;
            return(resp);
        }
コード例 #2
0
        public IEnumerable <T> GetResponses <T, U>(U request, Entity e, ref ushort msgId) where U : AbstractDIMSERequest where T : AbstractDIMSEResponse
        {
            System.DateTime lastContact = System.DateTime.Now;
            int             msWait      = 4000;

            var mr = new ManualResetEvent(false);

            List <T> responses = new List <T>();
            var      cr        = new Services.DIMSEService.DIMSEResponseHandler <T>((res, asc) =>
            {
                lastContact = System.DateTime.Now;
                responses.Add(res);
                if (res.Status != (ushort)Status.PENDING)
                {
                    mr.Set();
                }
                else
                {
                    mr.Reset();
                }
            });

            DIMSEService.Subscribe(cr);
            SendMessage(request, e);
            mr.WaitOne(msWait); //Max wait for timeout
            DIMSEService.Unsubscribe(cr);
            msgId += 2;
            return(responses);
        }
コード例 #3
0
 public DICOMServiceClass(Entity ae)
 {
     ApplicationEntity         = ae;
     SupportedTransferSyntaxes = new List <string>
     {
         TransferSyntaxHelper.IMPLICIT_VR_LITTLE_ENDIAN,
         TransferSyntaxHelper.EXPLICIT_VR_LITTLE_ENDIAN
     };
     SupportedAbstractSyntaxes = new List <string>();
     DIMSEService       = new DIMSEService();
     AssociationService = new AssociationService();
     Logger             = new EventLogger();
 }
コード例 #4
0
 public DICOMServiceClass(Entity ae)
 {
     ApplicationEntity = ae;
     SupportedTransferSyntaxes = new List<string>
     {
         TransferSyntaxHelper.IMPLICIT_VR_LITTLE_ENDIAN,
         TransferSyntaxHelper.EXPLICIT_VR_LITTLE_ENDIAN
     };
     SupportedAbstractSyntaxes = new List<string>();
     DIMSEService = new DIMSEService();
     AssociationService = new AssociationService();
     Logger = new EventLogger();
 }
コード例 #5
0
ファイル: DICOMSCU.cs プロジェクト: zzti/Evil-DICOM
        public IEnumerable <T> GetResponses <T, U>(U request, Entity e, ref ushort msgId) where U : AbstractDIMSERequest where T : AbstractDIMSEResponse
        {
            System.DateTime lastContact = System.DateTime.Now;
            int             msWait      = IdleTimeout;

            var      mr        = new ManualResetEvent(false);
            List <T> responses = new List <T>();
            var      cr        = new Services.DIMSEService.DIMSEResponseHandler <T>((res, asc) =>
            {
                asc.IdleClock.Restart();
                lastContact = System.DateTime.Now;
                responses.Add(res);
                if (res.Status != (ushort)Status.PENDING)
                {
                    mr.Set();
                }
                else
                {
                    mr.Reset();
                }
            });

            DIMSEService.Subscribe(cr);

            bool clientConnected;
            //Only wait if message is successful
            var sendStatus = SendMessage(request, e);

            if (clientConnected = sendStatus.WasAccepted)
            {
                //Wait for final response
                mr.WaitOne(msWait);
            }
            DIMSEService.Unsubscribe(cr);
            msgId += 2;

            if (!sendStatus.DidConnect)
            {
                throw new Exception($"Could not connect to remote endpoint {e}");
            }
            if (sendStatus.WasRejected)
            {
                throw new Exception($"Connected, but association refused by {e} : {sendStatus.Reason}");
            }
            return(responses);
        }