本文整理汇总了C#中Frame.Write方法的典型用法代码示例。如果您正苦于以下问题:C# Frame.Write方法的具体用法?C# Frame.Write怎么用?C# Frame.Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frame
的用法示例。
在下文中一共展示了Frame.Write方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteToFrameHeader
/// <summary>
/// Encode message into frame header
/// </summary>
/// <param name="frame">Frame to add message</param>
/// <returns>True on success</returns>
public bool WriteToFrameHeader(Frame frame)
{
if (frame == null || frame.LengthHeaderAvail < cLengthMax)
return false;
byte b = (byte)((int)Dispatch.Mesh << 6);
b |= 32; // originator is short addr
b |= 16; // target is short addr
if (HopsLeft < 15)
{
frame.AllocFront(cLengthMin);
b |= HopsLeft;
frame.Write(0, b);
frame.WriteCanonical(1, originatorAddress);
frame.WriteCanonical(3, finalAddress);
}
else
{
frame.AllocFront(cLengthMax);
b |= 15;
frame.Write(0, b);
frame.Write(1, HopsLeft);
frame.WriteCanonical(2, originatorAddress);
frame.WriteCanonical(4, finalAddress);
}
return true;
}
示例2: WriteToFrame
/// <summary>
/// Encode message into frame
/// </summary>
/// <param name="frame">Frame to add message</param>
/// <returns>True on success</returns>
public bool WriteToFrame(Frame frame)
{
if (frame == null || frame.LengthDataAvail < cLength)
return false;
frame.AllocBack(cLength);
byte Header = (Byte)((int)Type.AddressRequest << 2);
frame.Write(0, Header);
frame.Write(1, HopsLeft);
frame.WriteCanonical(2, BrokerAddr);
frame.WriteCanonical(4, DeviceAddr);
return true;
}
示例3: Main
static void Main(string[] args)
{
float[] frame1origin = new float[] { 0, 0, 0 };
float[] frame1XDirection = new float[] { 1, 0, 0 };
float[] frame1YDirection = new float[] { 0, 1, 0 };
Console.WriteLine(frame1YDirection[0] + " " + frame1YDirection[1] + " " + frame1YDirection[2]);
float[] frame1ZDirection = new float[] { 0, 0, 1 };
Frame frame1 = new Frame(frame1origin, frame1XDirection, frame1YDirection, frame1ZDirection);
Console.WriteLine("\nWriting frame1.vtp...");
// adjust path
frame1.Write(@"c:\vtk\vtkdata-5.8.0\Data\frame1.vtp");
float[] frame2origin = new float[] { 0, 0, 0 };
float[] frame2XDirection = new float[] { .707f, .707f, 0 };
float[] frame2YDirection = new float[] { -.707f, .707f, 0 };
float[] frame2ZDirection = new float[] { 0, 0, 1 };
Frame frame2 = new Frame(frame2origin, frame2XDirection, frame2YDirection, frame2ZDirection);
Console.WriteLine("\nWriting frame2.vtp...");
// adjust path
frame2.Write(@"c:\vtk\vtkdata-5.8.0\Data\frame2.vtp");
vtkTransform transform = vtkTransform.New();
AlignFrames(frame2, frame1, ref transform); // Brings frame2 to frame1
Console.WriteLine("\nWriting transformed.vtp...");
// adjust path
frame2.ApplyTransform(ref transform, @"c:\vtk\vtkdata-5.8.0\Data\transformed.vtp");
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
示例4: PhyDataIndication
/// <summary>
/// process frame from Phy layer. FCS has been removed already.
/// </summary>
/// <param name="sender"></param>
/// <param name="frame"></param>
/// <param name="linkQuality"></param>
public void PhyDataIndication(
IPhyDataSap sender,
ref Frame frame,
Byte linkQuality)
{
Frames.Type type;
bool ok = Header.GetType(frame, out type);
if (ok && type == Frames.Type.Data)
{
frame.AllocBack(1);
frame.Write(frame.LengthDataUsed - 1, linkQuality);
lock (_rxFrameQueue)
{
_rxFrameQueue.AddFrame(ref frame);
}
_rxEvent.Set();
Frame.Release(ref frame);
return;
}
Header hdr = new Header();
if (hdr.ReadFromFrameHeader(frame, true))
{
switch (hdr.fcs.Type)
{
case Microsoft.SPOT.Wireless.IEEE_802_15_4.Mac.Frames.Type.Beacon:
ReceiveBeacon(hdr, ref frame, linkQuality);
break;
case Microsoft.SPOT.Wireless.IEEE_802_15_4.Mac.Frames.Type.Cmd:
ReceiveCommand(hdr, ref frame, linkQuality);
break;
default:
// drop, data and ack frames are handled before
break;
}
}
}
示例5: WriteToFrameHeader
/// <summary>
/// Encode message into frame header
/// </summary>
/// <param name="frame">Frame to add message</param>
/// <returns>True on success</returns>
public bool WriteToFrameHeader(Frame frame)
{
if (frame == null || frame.LengthDataAvail < cLength)
return false;
frame.AllocFront(cLength);
byte Header = (Byte)((int)Type.Data << 2);
frame.Write(0, Header);
return true;
}