本文整理汇总了C#中Windows.Storage.Streams.DataWriter.WriteDouble方法的典型用法代码示例。如果您正苦于以下问题:C# DataWriter.WriteDouble方法的具体用法?C# DataWriter.WriteDouble怎么用?C# DataWriter.WriteDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.Storage.Streams.DataWriter
的用法示例。
在下文中一共展示了DataWriter.WriteDouble方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendMotorCmd
public async Task<bool> SendMotorCmd(bool on, int tilt, int forward, int turn, int up, float scale)
{
var packet = new DataWriter();
try
{
packet.WriteByte(2);
packet.WriteByte((byte)_motorCounter);
packet.WriteByte(2);
packet.WriteByte(0);
packet.WriteByte(2);
packet.WriteByte(0);
if (on)
{
packet.WriteByte(1);
}
else
{
packet.WriteByte(0);
}
// is byte casting necessary???
packet.WriteByte((byte)(tilt & 0xFF));
packet.WriteByte((byte)(forward & 0xFF));
packet.WriteByte((byte)(turn & 0xFF));
packet.WriteByte((byte)(up & 0xFF));
packet.WriteDouble(scale); // well, but I need different endian :(
//byte[] tmpArr = stream.toByteArray();
//byte tmp;
//tmp = tmpArr[11]; // temporary hack - swapping float ordering
//tmpArr[11] = tmpArr[14];
//tmpArr[14] = tmp;
//tmp = tmpArr[12];
//tmpArr[12] = tmpArr[13];
//tmpArr[13] = tmp;
//characteristics.setValue(tmpArr);
await _motorChar.WriteValueAsync(packet.DetachBuffer(), GattWriteOption.WriteWithoutResponse);
}
catch (Exception exception)
{
AddException(exception);
}
await Sleep(50);
_motorCounter++;
return true;
}
示例2: ButtonAction5_Click
private async void ButtonAction5_Click(object sender, RoutedEventArgs e)
{
DevicesInformation = string.Empty;
try
{
var motors = _dicCharacteristics["Parrot_PowerMotors"].Characteristic;
await motors.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Indicate);
byte[] arr1 = { 02, 40, 20, 09, 00, 05, 00, 04, 00, 12, 0xC0, 00, 01, 00 };
var buffer = new DataWriter();
buffer.WriteInt16(2);
buffer.WriteInt16(1);
buffer.WriteInt16(2);
buffer.WriteInt16(0);
buffer.WriteInt16(2);
buffer.WriteInt16(0);
buffer.WriteInt16(1);
buffer.WriteInt16(1);
buffer.WriteInt16(1);
buffer.WriteInt16(1);
buffer.WriteInt16(1);
buffer.WriteDouble(0);
await motors.WriteValueAsync(buffer.DetachBuffer(), GattWriteOption.WriteWithoutResponse);
DevicesInformation += $" - 1 OK{Environment.NewLine}";
}
catch (Exception exception)
{
DevicesInformation += $" - ERROR {exception.Message}{Environment.NewLine}";
}
}
示例3: SendMotorCommand
public async Task<bool> SendMotorCommand(bool @on, int tilt, int forward, int turn, int up, float scale, IReadOnlyList<GattCharacteristic> characteristics)
{
var res = false;
var characteristic = characteristics[0];
try
{
Debug.WriteLine(" Send Motor Command");
Debug.WriteLine(" Try to write to " + CharacteristicUuidsResolver.GetNameFromUuid(characteristic.Uuid));
Debug.WriteLine(" Char props" + characteristic.CharacteristicProperties);
var writer = new DataWriter();
writer.WriteByte(2);
writer.WriteByte((byte)_motorCounter);
writer.WriteByte(2);
writer.WriteByte(0);
writer.WriteByte(2);
writer.WriteByte(0);
if (on)
{
writer.WriteByte(1);
}
else
{
writer.WriteByte(0);
}
// is byte casting necessary???
writer.WriteByte((byte)(tilt & 0xFF));
writer.WriteByte((byte)(forward & 0xFF));
writer.WriteByte((byte)(turn & 0xFF));
writer.WriteByte((byte)(up & 0xFF));
writer.WriteDouble(scale); // well, but I need different endian :(
await characteristic.WriteValueAsync(writer.DetachBuffer());
Debug.WriteLine(" Write sucessfull");
res = true;
}
catch (Exception exception)
{
Debug.WriteLine(" Write error");
}
return res;
}