本文整理汇总了C#中Dicom.Network.RawPDU.ReadUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# RawPDU.ReadUInt16方法的具体用法?C# RawPDU.ReadUInt16怎么用?C# RawPDU.ReadUInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dicom.Network.RawPDU
的用法示例。
在下文中一共展示了RawPDU.ReadUInt16方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
/// <summary>
/// Reads A-ASSOCIATE-AC from PDU buffer
/// </summary>
/// <param name="raw">PDU buffer</param>
public void Read(RawPDU raw) {
// reset async ops in case remote end does not negotiate
_assoc.MaxAsyncOpsInvoked = 1;
_assoc.MaxAsyncOpsPerformed = 1;
uint l = raw.Length - 6;
ushort c = 0;
raw.ReadUInt16("Version");
raw.SkipBytes("Reserved", 2);
raw.SkipBytes("Reserved", 16);
raw.SkipBytes("Reserved", 16);
raw.SkipBytes("Reserved", 32);
l -= 68;
while (l > 0) {
byte type = raw.ReadByte("Item-Type");
l -= 1;
if (type == 0x10) {
// Application Context
raw.SkipBytes("Reserved", 1);
c = raw.ReadUInt16("Item-Length");
raw.SkipBytes("Value", (int)c);
l -= 3 + (uint)c;
} else
if (type == 0x21) {
// Presentation Context
raw.ReadByte("Reserved");
ushort pl = raw.ReadUInt16("Presentation Context Item-Length");
byte id = raw.ReadByte("Presentation Context ID");
raw.ReadByte("Reserved");
byte res = raw.ReadByte("Presentation Context Result/Reason");
raw.ReadByte("Reserved");
l -= (uint)pl + 3;
pl -= 4;
// Presentation Context Transfer Syntax
raw.ReadByte("Presentation Context Item-Type (0x40)");
raw.ReadByte("Reserved");
ushort tl = raw.ReadUInt16("Presentation Context Item-Length");
string tx = raw.ReadString("Presentation Context Syntax UID", tl);
pl -= (ushort)(tl + 4);
_assoc.PresentationContexts[id].SetResult((DicomPresentationContextResult)res, DicomTransferSyntax.Parse(tx));
} else if (type == 0x50) {
// User Information
raw.ReadByte("Reserved");
ushort il = raw.ReadUInt16("User Information Item-Length");
l -= (uint)(il + 3);
while (il > 0) {
byte ut = raw.ReadByte("User Item-Type");
raw.ReadByte("Reserved");
ushort ul = raw.ReadUInt16("User Item-Length");
il -= (ushort)(ul + 4);
if (ut == 0x51) {
_assoc.MaximumPDULength = raw.ReadUInt32("Max PDU Length");
} else if (ut == 0x52) {
_assoc.RemoteImplemetationClassUID = DicomUID.Parse(raw.ReadString("Implementation Class UID", ul));
} else if (ut == 0x53) {
_assoc.MaxAsyncOpsInvoked = raw.ReadUInt16("Asynchronous Operations Invoked");
_assoc.MaxAsyncOpsPerformed = raw.ReadUInt16("Asynchronous Operations Performed");
} else if (ut == 0x55) {
_assoc.RemoteImplementationVersion = raw.ReadString("Implementation Version", ul);
} else {
raw.SkipBytes("User Item Value", (int)ul);
}
}
} else {
raw.SkipBytes("Reserved", 1);
ushort il = raw.ReadUInt16("User Item-Length");
raw.SkipBytes("Unknown User Item", il);
l -= (uint)(il + 3);
}
}
}
示例2: Read
/// <summary>
/// Reads A-ASSOCIATE-AC from PDU buffer
/// </summary>
/// <param name="raw">PDU buffer</param>
public void Read(RawPDU raw)
{
uint l = raw.Length;
ushort c = 0;
raw.ReadUInt16("Version");
raw.SkipBytes("Reserved", 2);
raw.SkipBytes("Reserved", 16);
raw.SkipBytes("Reserved", 16);
raw.SkipBytes("Reserved", 32);
l -= 68;
while (l > 0) {
byte type = raw.ReadByte("Item-Type");
l -= 1;
if (type == 0x10) {
// Application Context
raw.SkipBytes("Reserved", 1);
c = raw.ReadUInt16("Item-Length");
raw.SkipBytes("Value", (int)c);
l -= 3 + (uint)c;
} else
if (type == 0x21) {
// Presentation Context
raw.ReadByte("Reserved");
ushort pl = raw.ReadUInt16("Presentation Context Item-Length");
byte id = raw.ReadByte("Presentation Context ID");
raw.ReadByte("Reserved");
byte res = raw.ReadByte("Presentation Context Result/Reason");
raw.ReadByte("Reserved");
l -= (uint)pl + 3;
pl -= 4;
// Presentation Context Transfer Syntax
raw.ReadByte("Presentation Context Item-Type (0x40)");
raw.ReadByte("Reserved");
ushort tl = raw.ReadUInt16("Presentation Context Item-Length");
string tx = raw.ReadString("Presentation Context Syntax UID", tl);
pl -= (ushort)(tl + 4);
_assoc.SetPresentationContextResult(id, (DcmPresContextResult)res);
_assoc.SetAcceptedTransferSyntax(id, DicomTransferSyntax.Lookup(tx));
} else
if (type == 0x50) {
// User Information
raw.ReadByte("Reserved");
ushort il = raw.ReadUInt16("User Information Item-Length");
l -= (uint)(il + 3);
while (il > 0) {
byte ut = raw.ReadByte("User Item-Type");
raw.ReadByte("Reserved");
ushort ul = raw.ReadUInt16("User Item-Length");
il -= (ushort)(ul + 4);
if (ut == 0x51) {
_assoc.MaximumPduLength = raw.ReadUInt32("Max PDU Length");
} else if (ut == 0x52) {
_assoc.ImplementationClass = DicomUID.Lookup(raw.ReadString("Implementation Class UID", ul));
} else if (ut == 0x53) {
_assoc.AsyncOpsInvoked = raw.ReadUInt16("Asynchronous Operations Invoked");
_assoc.AsyncOpsPerformed = raw.ReadUInt16("Asynchronous Operations Performed");
} else if (ut == 0x55) {
_assoc.ImplementationVersion = raw.ReadString("Implementation Version", ul);
} else {
raw.SkipBytes("User Item Value", (int)ul);
}
}
}
else {
raw.SkipBytes("Reserved", 1);
ushort il = raw.ReadUInt16("User Item-Length");
raw.SkipBytes("Unknown User Item", il);
l -= (uint)(il + 3);
}
}
}
示例3: Read
/// <summary>
/// Reads A-ASSOCIATE-RQ from PDU buffer
/// </summary>
/// <param name="raw">PDU buffer</param>
public void Read(RawPDU raw)
{
uint l = raw.Length - 6;
raw.ReadUInt16("Version");
raw.SkipBytes("Reserved", 2);
_assoc.CalledAE = raw.ReadString("Called AE", 16);
_assoc.CallingAE = raw.ReadString("Calling AE", 16);
raw.SkipBytes("Reserved", 32);
l -= 2 + 2 + 16 + 16 + 32;
while (l > 0)
{
byte type = raw.ReadByte("Item-Type");
raw.SkipBytes("Reserved", 1);
ushort il = raw.ReadUInt16("Item-Length");
l -= 4 + (uint)il;
if (type == 0x10)
{
// Application Context
raw.SkipBytes("Application Context", il);
}
else if (type == 0x20)
{
// Presentation Context
byte id = raw.ReadByte("Presentation Context ID");
raw.SkipBytes("Reserved", 3);
il -= 4;
while (il > 0)
{
byte pt = raw.ReadByte("Presentation Context Item-Type");
raw.SkipBytes("Reserved", 1);
ushort pl = raw.ReadUInt16("Presentation Context Item-Length");
string sx = raw.ReadString("Presentation Context Syntax UID", pl);
if (pt == 0x30)
{
var pc = new DicomPresentationContext(id, DicomUID.Parse(sx));
_assoc.PresentationContexts.Add(pc);
}
else if (pt == 0x40)
{
var pc = _assoc.PresentationContexts[id];
pc.AddTransferSyntax(DicomTransferSyntax.Parse(sx));
}
il -= (ushort)(4 + pl);
}
}
else if (type == 0x50)
{
// User Information
while (il > 0)
{
byte ut = raw.ReadByte("User Information Item-Type");
raw.SkipBytes("Reserved", 1);
ushort ul = raw.ReadUInt16("User Information Item-Length");
il -= (ushort)(4 + ul);
if (ut == 0x51)
{
_assoc.MaximumPDULength = raw.ReadUInt32("Max PDU Length");
}
else if (ut == 0x52)
{
_assoc.RemoteImplementationClassUID =
new DicomUID(
raw.ReadString("Implementation Class UID", ul),
"Implementation Class UID",
DicomUidType.Unknown);
}
else if (ut == 0x55)
{
_assoc.RemoteImplementationVersion = raw.ReadString("Implementation Version", ul);
}
else if (ut == 0x53)
{
_assoc.MaxAsyncOpsInvoked = raw.ReadUInt16("Asynchronous Operations Invoked");
_assoc.MaxAsyncOpsPerformed = raw.ReadUInt16("Asynchronous Operations Performed");
}
else if (ut == 0x54)
{
var asul = raw.ReadUInt16("Abstract Syntax Item-Length");
var syntax = raw.ReadString("Abstract Syntax UID", asul);
var userRole = raw.ReadByte("SCU role");
var providerRole = raw.ReadByte("SCP role");
var pc =
_assoc.PresentationContexts.FirstOrDefault(
context => context.AbstractSyntax.UID.Equals(syntax));
if (pc != null)
{
pc.UserRole = userRole == 0x01;
pc.ProviderRole = providerRole == 0x01;
}
}
else if (ut == 0x56)
//.........这里部分代码省略.........
示例4: Create
/// <summary>
/// Factory method for creating <see cref="DicomExtendedNegotiation"/> instances.
/// </summary>
/// <param name="raw">Raw PDU.</param>
/// <param name="length">Length.</param>
/// <returns>A new <see cref="DicomExtendedNegotiation"/> instance.</returns>
public static DicomExtendedNegotiation Create(RawPDU raw, ushort length)
{
var uidLen = raw.ReadUInt16("SOP Class UID Length");
var uidStr = raw.ReadString("SOP Class UID", uidLen);
var uid = DicomUID.Parse(uidStr);
IExtendedNegotiationSubItem subItem = null;
var subItemSize = 0;
var remaining = length - uidLen - 2;
if (subItemCreators.ContainsKey(uid))
{
subItem = subItemCreators[uid](raw, remaining, out subItemSize);
}
remaining -= subItemSize;
if (remaining > 0)
{
raw.SkipBytes("Unread bytes", remaining);
}
return new DicomExtendedNegotiation(uid, subItem);
}