internal AssociateAcceptPDU ToPDU(AssociateRequestPDU requestPDU) { var pdu = new AssociateAcceptPDU(); requestPDU.CalledAETitle.AsSpan().CopyTo(pdu.CopiedFromAssociateRequestPDU_1); requestPDU.CallingAETitle.AsSpan().CopyTo(pdu.CopiedFromAssociateRequestPDU_2); requestPDU.Reserved.AsSpan().CopyTo(pdu.CopiedFromAssociateRequestPDU_3); pdu.Items.Add(new ApplicationContextItem { ApplicationContextName = Encoding.ASCII.GetBytes(NetUtils.DicomApplicationContextName) }); foreach (var presentationContextResponse in PresentationContextResponses) { pdu.Items.Add(presentationContextResponse.ToItem()); } var userInformationItem = new UserInformationItem(); if (MaxDataTransferPDULength.HasValue) { userInformationItem.SubItems.Add(new MaximumLengthSubItem { MaximumLength = MaxDataTransferPDULength.Value }); } pdu.Items.Add(userInformationItem); return(pdu); }
internal AssociateRequestPDU ToPDU() { var pdu = new AssociateRequestPDU(); NetUtils.WriteAsciiStringTo(CalledAETitle, pdu.CalledAETitle); NetUtils.WriteAsciiStringTo(CallingAETitle, pdu.CallingAETitle); pdu.Items.Add(new ApplicationContextItem { ApplicationContextName = Encoding.ASCII.GetBytes(NetUtils.DicomApplicationContextName) }); foreach (var presentationContextRequest in PresentationContextRequests) { pdu.Items.Add(presentationContextRequest.ToItem()); } var userInformationItem = new UserInformationItem(); if (MaxDataTransferPDULength.HasValue) { userInformationItem.SubItems.Add(new MaximumLengthSubItem { MaximumLength = MaxDataTransferPDULength.Value }); } pdu.Items.Add(userInformationItem); return(pdu); }
public AssociationRequest ReceiveAssociationRequest() { _associateRequestPDU = (AssociateRequestPDU)ReadNextPDU(DataUnitType.AssociateRequestPDU); var associationRequest = AssociationRequest.FromPDU(_associateRequestPDU); MaxDataTransferPDULengthRequestedByPeer = associationRequest.MaxDataTransferPDULength; return(associationRequest); }
internal static AssociationRequest FromPDU(AssociateRequestPDU pdu) { var associationRequest = new AssociationRequest { CalledAETitle = NetUtils.ReadAsciiStringFrom(pdu.CalledAETitle), CallingAETitle = NetUtils.ReadAsciiStringFrom(pdu.CallingAETitle) }; foreach (var item in pdu.Items) { if (item is ApplicationContextItem applicationContextItem) { var applicationContextName = Encoding.ASCII.GetString(applicationContextItem.ApplicationContextName); if (applicationContextName != NetUtils.DicomApplicationContextName) { throw new NotSupportedException($"Unsupported application context name '{applicationContextName}'"); } } else if (item is PresentationContextRequestItem presentationContextItem) { associationRequest.PresentationContextRequests.Add(PresentationContextRequest.FromItem(presentationContextItem)); } else if (item is UserInformationItem userInformationItem) { foreach (var subItem in userInformationItem.SubItems) { if (subItem is MaximumLengthSubItem maximumLengthSubItem) { associationRequest.MaxDataTransferPDULength = maximumLengthSubItem.MaximumLength; } } } } return(associationRequest); }