當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。