Write() 공개 메소드

Writes A-ASSOCIATE-RQ to PDU buffer
public Write ( ) : RawPDU
리턴 RawPDU
예제 #1
0
파일: PDUTest.cs 프로젝트: GMZ/fo-dicom
        public void Write_AeWithNonAsciiCharacters_ShouldBeAsciified()
        {
            var notExpected = "GÖTEBORG";
            var request = new AAssociateRQ(new DicomAssociation("MALMÖ", notExpected));

            var writePdu = request.Write();

            RawPDU readPdu;
            using (var stream = new MemoryStream())
            {
                writePdu.WritePDU(stream);

                var length = (int)writePdu.Length;
                var buffer = new byte[length];
                stream.Seek(0, SeekOrigin.Begin);
                stream.Read(buffer, 0, length);
                readPdu = new RawPDU(buffer);
            }

            readPdu.Reset();
            readPdu.SkipBytes("Unknown", 10);
            var actual = readPdu.ReadString("Called AE", 16);

            Assert.NotEqual(notExpected, actual);
        }
예제 #2
0
        public void Write_AeWithNonAsciiCharacters_ShouldBeAsciified()
        {
            var notExpected = "GÖTEBORG";
            var request = new AAssociateRQ(new DicomAssociation("MALMÖ", notExpected));

            var writePdu = request.Write();

            RawPDU readPdu;
            using (var stream = new MemoryStream())
            {
                writePdu.WritePDU(stream);

                var length = (int)writePdu.Length;
                var buffer = new byte[length];
                stream.Seek(0, SeekOrigin.Begin);
                stream.Read(buffer, 0, length);
                readPdu = new RawPDU(buffer);
            }

            readPdu.Reset();
            readPdu.SkipBytes("Unknown", 10);
            var actual = readPdu.ReadString("Called AE", 16);

            Assert.NotEqual(notExpected, actual);
        }
예제 #3
0
        public void AssociateRQ_WriteRead_ExpectedExtendedNegotiation(DicomUID sopClassUid, DicomServiceApplicationInfo applicationInfo, DicomUID commonServiceClass, DicomUID[] relatedSopClasses)
        {
            var association = new DicomAssociation("testCalling", "testCalled");

            association.ExtendedNegotiations.Add(sopClassUid, applicationInfo, commonServiceClass, relatedSopClasses);

            var rq       = new AAssociateRQ(association);
            var writePdu = rq.Write();

            var readPdu = ConvertWriteToReadPdu(writePdu);

            var testAssociation = new DicomAssociation();
            var rq2             = new AAssociateRQ(testAssociation);

            rq2.Read(readPdu);

            Assert.Single(testAssociation.ExtendedNegotiations);
            var negotiation = testAssociation.ExtendedNegotiations.First();

            Assert.Equal(sopClassUid, negotiation.SopClassUid);
            Assert.Equal(applicationInfo, negotiation.RequestedApplicationInfo);
            Assert.Equal(commonServiceClass, negotiation.ServiceClassUid);
            Assert.Equal(relatedSopClasses, negotiation.RelatedGeneralSopClasses);
            Assert.Null(negotiation.AcceptedApplicationInfo);
        }
예제 #4
0
        public void Write_AeWithNonAsciiCharacters_ShouldBeAsciified()
        {
            var notExpected = "GÖTEBORG";
            var request     = new AAssociateRQ(new DicomAssociation("MALMÖ", notExpected));

            var writePdu = request.Write();
            var readPdu  = ConvertWriteToReadPdu(writePdu);

            readPdu.Reset();
            readPdu.SkipBytes("Unknown", 10);
            var actual = readPdu.ReadString("Called AE", 16);

            Assert.NotEqual(notExpected, actual);
        }
예제 #5
0
        public void WriteReadAAssociateRQExtendedNegotiation()
        {
            DicomAssociation association = new DicomAssociation("testCalling", "testCalled");

            association.ExtendedNegotiations.Add(
                new DicomExtendedNegotiation(
                    DicomUID.StudyRootQueryRetrieveInformationModelFIND,
                    new RootQueryRetrieveInfoFind(1, 1, 1, 1, null)));

            AAssociateRQ rq = new AAssociateRQ(association);

            RawPDU writePdu = rq.Write();

            RawPDU readPdu;

            using (MemoryStream stream = new MemoryStream())
            {
                writePdu.WritePDU(stream);

                int    length = (int)stream.Length;
                byte[] buffer = new byte[length];
                stream.Seek(0, SeekOrigin.Begin);
                stream.Read(buffer, 0, length);
                readPdu = new RawPDU(buffer);
            }

            DicomAssociation testAssociation = new DicomAssociation();
            AAssociateRQ     rq2             = new AAssociateRQ(testAssociation);

            rq2.Read(readPdu);

            Assert.True(testAssociation.ExtendedNegotiations.Count == 1);
            Assert.True(
                testAssociation.ExtendedNegotiations[0].SopClassUid
                == DicomUID.StudyRootQueryRetrieveInformationModelFIND);

            RootQueryRetrieveInfoFind info =
                testAssociation.ExtendedNegotiations[0].SubItem as RootQueryRetrieveInfoFind;

            Assert.True(null != info);
            Assert.True(
                (1 == info.DateTimeMatching) && (1 == info.FuzzySemanticMatching) && (1 == info.RelationalQueries) &&
                (1 == info.TimezoneQueryAdjustment) && (false == info.EnhancedMultiFrameImageConversion.HasValue));
        }
예제 #6
0
파일: PDUTest.cs 프로젝트: aerik/fo-dicom
        public void WriteReadAAssociateRQExtendedNegotiation()
        {
            DicomAssociation association = new DicomAssociation("testCalling", "testCalled");
            association.ExtendedNegotiations.Add(
                new DicomExtendedNegotiation(
                    DicomUID.StudyRootQueryRetrieveInformationModelFIND,
                    new RootQueryRetrieveInfoFind(1, 1, 1, 1, null)));

            AAssociateRQ rq = new AAssociateRQ(association);

            RawPDU writePdu = rq.Write();

            RawPDU readPdu;
            using (MemoryStream stream = new MemoryStream())
            {
                writePdu.WritePDU(stream);

                int length = (int)stream.Length;
                byte[] buffer = new byte[length];
                stream.Seek(0, SeekOrigin.Begin);
                stream.Read(buffer, 0, length);
                readPdu = new RawPDU(buffer);
            }

            DicomAssociation testAssociation = new DicomAssociation();
            AAssociateRQ rq2 = new AAssociateRQ(testAssociation);
            rq2.Read(readPdu);

            Assert.True(testAssociation.ExtendedNegotiations.Count == 1);
            Assert.True(
                testAssociation.ExtendedNegotiations[0].SopClassUid
                == DicomUID.StudyRootQueryRetrieveInformationModelFIND);

            RootQueryRetrieveInfoFind info =
                testAssociation.ExtendedNegotiations[0].SubItem as RootQueryRetrieveInfoFind;
            Assert.True(null != info);
            Assert.True(
                (1 == info.DateTimeMatching) && (1 == info.FuzzySemanticMatching) && (1 == info.RelationalQueries)
                && (1 == info.TimezoneQueryAdjustment) && (false == info.EnhancedMultiFrameImageConversion.HasValue));
        }
예제 #7
0
 /// <summary>
 /// A DICOM Application Entity (which includes the Upper Layer service-user) 
 /// that desires to establish an association shall issue an A-ASSOCIATE request 
 /// primitive. The called AE is identified by parameters of the request 
 /// primitive. The requestor shall not issue any primitives except an A-ABORT 
 /// request primitive until it receives an A-ASSOCIATE confirmation primitive.
 /// </summary>
 /// <param name="associate"></param>
 protected void SendAssociateRequest(DcmAssociate associate)
 {
     _assoc = associate;
     Log.Info("{0} -> Association request:\n{1}", LogID, Associate.ToString());
     AAssociateRQ pdu = new AAssociateRQ(_assoc);
     SendRawPDU(pdu.Write());
 }
예제 #8
0
 /// <summary>
 /// A DICOM Application Entity (which includes the Upper Layer service-user) 
 /// that desires to establish an association shall issue an A-ASSOCIATE request 
 /// primitive. The called AE is identified by parameters of the request 
 /// primitive. The requestor shall not issue any primitives except an A-ABORT 
 /// request primitive until it receives an A-ASSOCIATE confirmation primitive.
 /// </summary>
 /// <param name="associate"></param>
 protected void SendAssociateRequest(DcmAssociate associate)
 {
     _assoc = associate;
     if (UseRemoteAeForLogName) {
         LogID = Associate.CalledAE;
         Log = LogManager.GetLogger(LogID);
     }
     Log.Info("{0} -> Association request:\n{1}", LogID, Associate.ToString());
     AAssociateRQ pdu = new AAssociateRQ(_assoc);
     SendRawPDU(pdu.Write());
 }