public void AssociateAC_WriteRead_ExpectedExtendedNegotiation(DicomUID sopClassUid, DicomServiceApplicationInfo applicationInfo, DicomUID commonServiceClass, DicomUID[] relatedSopClasses) { var inAssociation = new DicomAssociation("testCalling", "testCalled"); inAssociation.ExtendedNegotiations.Add(sopClassUid, applicationInfo, commonServiceClass, relatedSopClasses); var acceptedApplicationInfo = new DicomServiceApplicationInfo(applicationInfo.GetValues()); acceptedApplicationInfo.AddOrUpdate(1, 10); inAssociation.ExtendedNegotiations.AcceptApplicationInfo(sopClassUid, acceptedApplicationInfo); var ac = new AAssociateAC(inAssociation); var writePdu = ac.Write(); var readPdu = ConvertWriteToReadPdu(writePdu); var outAssociation = new DicomAssociation(); outAssociation.ExtendedNegotiations.Add(sopClassUid, applicationInfo); var ac2 = new AAssociateAC(outAssociation); ac2.Read(readPdu); Assert.Single(outAssociation.ExtendedNegotiations); var negotiation = outAssociation.ExtendedNegotiations.First(); Assert.Equal(sopClassUid, negotiation.SopClassUid); Assert.Equal(applicationInfo, negotiation.RequestedApplicationInfo); Assert.Equal(acceptedApplicationInfo, negotiation.AcceptedApplicationInfo); Assert.Null(negotiation.ServiceClassUid); Assert.Empty(negotiation.RelatedGeneralSopClasses); }
public void AssociateAC_Read_TransferSyntaxIdentifiedIfAccept(byte[] buffer, byte contextId, DicomPresentationContextResult result, DicomTransferSyntax syntax) { var association = new DicomAssociation(); association.PresentationContexts.Add( new DicomPresentationContext(contextId, DicomUID.Verification)); using var raw = new RawPDU(buffer); var accept = new AAssociateAC(association); accept.Read(raw); var actual = association.PresentationContexts[contextId]; Assert.Equal(result, actual.Result); Assert.Equal(syntax, actual.AcceptedTransferSyntax); }
internal override void Write(AAssociateAC ac) { try { ac.WriteTo(m_fsm.stream); } catch (IOException e) { m_fsm.ChangeState(m_fsm.STA1); throw e; } m_fsm.ChangeState(m_fsm.STA6); }
internal virtual void Write(AAssociateAC ac) { throw new SystemException(); }
public void Write(AAssociateAC ac) { FireWrite(ac); try { lock (stream) { state.Write(ac); } } catch (IOException ioe) { if (assocListener != null) { assocListener.Error(assoc, ioe); } throw ioe; } this.ac = ac; }
private int CreateAssociateSession() { UnparsePDU u; try { var associateRq = new AAssociateRQ(16384, LocalAETitle, PrinterAETitle); tcpClient.Connect(IPAddress.Parse(PrinterAddress), Convert.ToInt16(PrinterPort)); if (tcpClient.Connected) { byte[] byteBuffer = associateRq.CreateByteBuff(); _stream.Write(byteBuffer, 0, byteBuffer.Length); var _receiveBuffer = new byte[16384]; u = new UnparsePDU(_stream, _receiveBuffer); if (u.PDUType.Equals(2)) { var associateAC = new AAssociateAC(); //var nget = new N_GET(); } else if (u.PDUType.Equals(7)) { tcpClient.Close(); return u.Buff[9]; } } } catch (Exception ex) { _logger.FatalException("Exception", ex); } return -1; }