private RawPDU ConvertWriteToReadPdu(RawPDU writePdu) { 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); return(new RawPDU(buffer)); } }
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)); }
private void WritePDU(bool last) { if (_pdu.PDVs.Count == 0 || ((CurrentPduSize() + 6) < _max && GetBufferLength() > 0)) { CreatePDV(); } if (_pdu.PDVs.Count > 0) { if (last) { _pdu.PDVs[_pdu.PDVs.Count - 1].IsLastFragment = true; } RawPDU raw = _pdu.Write(); raw.WritePDU(_network); if (OnPduSent != null) { OnPduSent(); } _pdu = new PDataTF(); } }
private void SendRawPDU(RawPDU pdu) { try { lock (_socket) { _disableTimeout = true; pdu.WritePDU(_network); _disableTimeout = false; } } catch (Exception e) { #if DEBUG Log.Error("{0} -> Error sending PDU [type: 0x{1:x2}]: {2}", LogID, pdu.Type, e.ToString()); #else Log.Error("{0} -> Error sending PDU [type: 0x{1:x2}]: {2}", LogID, pdu.Type, e.Message); #endif OnNetworkError(e); } }