private AssociateRequestPdu GetAssociationRequestPdu() { //Logging.Log("Association.GetAssociationRequestPdu"); AssociateRequestPdu pdu = new AssociateRequestPdu(ProtocolDataUnit.Type.A_ASSOCIATE_RQ, scp.Title, scu.Title); ApplicationContextItem ac = new ApplicationContextItem("1.2.840.10008.3.1.1.1"); pdu.fields.Add(ac); foreach (ServiceClass service in services) { service.PresentationContextId = index; index += 2; PresentationContextItem pci = new PresentationContextItem((byte)ItemType.PresentationContextItemRQ, service.PresentationContextId); pdu.fields.Add(pci); SyntaxItem abs = new SyntaxItem((byte)ItemType.AbstractSyntaxSubItem, service.SOPClassUId); pci.fields.Add(abs); foreach (string syntax in service.Syntaxes) { SyntaxItem trx = new SyntaxItem((byte)ItemType.TransferSyntaxSubItem, syntax); pci.fields.Add(trx); } } UserInfoItem user = new UserInfoItem(); pdu.fields.Add(user); MaximumLengthItem ml = new MaximumLengthItem(MaxPduSize); user.fields.Add(ml); SyntaxItem impl = new SyntaxItem((byte)ItemType.ImplementationClassUidSubItem, "1.2.840.113564.3.2"); user.fields.Add(impl); AsynchronousOperationsWindowItem operations = new AsynchronousOperationsWindowItem(); user.fields.Add(operations); foreach (ServiceClass service in services) { ScpScuRoleSelectionItem role = new ScpScuRoleSelectionItem(service.SOPClassUId, service.Role); user.fields.Add(role); } SyntaxItem implver = new SyntaxItem((byte)ItemType.ImplementationVersionNameSubItem, "not specified"); user.fields.Add(implver); return(pdu); }
public override long Read(Stream stream) { long bytes = 0; if (stream.CanRead) { EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big); long start = stream.Position; base.Read(stream); byte next = reader.PeekByte(); Item item = null; while (next > 0x50) { switch (next) { case (byte)ItemType.MaximumLengthSubItem: // 0x51: item = new MaximumLengthItem(); break; case (byte)ItemType.ImplementationClassUidSubItem: // 0x52: case (byte)ItemType.ImplementationVersionNameSubItem: // 0x55: item = new SyntaxItem(next); break; case (byte)ItemType.AsynchronousOperationsWindowSubItem: // 0x53: item = new AsynchronousOperationsWindowItem(); break; case (byte)ItemType.ScuScpRoleSubItem: // 0x54: item = new ScpScuRoleSelectionItem(); break; default: Debug.Assert(false, String.Format("Unknown User Info Item {0}.", next)); break; } fields.Add(item); item.Read(stream); if (stream.Position >= stream.Length) { break; } next = reader.PeekByte(); } if (fields.Count < 1) { throw new Exception("Ill-formed User Info Item."); } bytes = stream.Position - start; } return(bytes); }