当前位置: 首页>>代码示例>>C#>>正文


C# DataWriter.WriteDouble方法代码示例

本文整理汇总了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;
        }
开发者ID:modulexcite,项目名称:events,代码行数:45,代码来源:TourTheStairs.cs

示例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}";
            }


        }
开发者ID:modulexcite,项目名称:events,代码行数:34,代码来源:MainPage.xaml.cs

示例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;
        }
开发者ID:modulexcite,项目名称:events,代码行数:42,代码来源:ParrotSendData.cs


注:本文中的Windows.Storage.Streams.DataWriter.WriteDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。