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


C# Frame.Get方法代码示例

本文整理汇总了C#中LibZano.Frame.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Frame.Get方法的具体用法?C# Frame.Get怎么用?C# Frame.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LibZano.Frame的用法示例。


在下文中一共展示了Frame.Get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            uint zano;
            Library.Initialise("Example-GetAltitude.1.0.0");
            zano = Library.Obtain("192.168.0.1", 10001);

            bool isConnected = false;
            Frame frame = new Frame();

            Library.Connect(zano);

            while (true)
            {
                if (isConnected)
                {
                    Frames.FlightAltitudeGet(zano);
                }

                Library.Tick();

                while (Library.Receive(ref frame) == 1)
                {
                    switch (frame.Reference)
                    {
                        case Symbols.kFlightAltitudeGet:
                        {
                            int altitude = frame.Get(Symbols.kAltitude);
                            Console.WriteLine(String.Format("Altitude is {0} mm", altitude));
                        }
                        break;
                    }
                }

                Library.Status status;

                while ((status = Library.GetStatus()) != Library.Status.None)
                {
                    switch (status)
                    {
                        case Library.Status.DeviceDisconnectionDisconnected:
                        case Library.Status.DeviceConnectionNotConnected:
                        case Library.Status.DeviceConnectionHeldStill:
                        {
                            isConnected = false;
                            Library.Connect(zano);
                        }
                        break;
                        case Library.Status.DeviceConnectionConnected:
                        {
                            isConnected = true;
                        }
                        break;
                    }
                }

                Thread.Sleep(10);
            }
        }
开发者ID:torquing,项目名称:libZanoDotNet,代码行数:58,代码来源:Program.cs

示例2: Tick

        public static void Tick()
        {
            if (Initialised && CanTick)
            {
                A.Trigger("tick");

                LibZano.Library.GetFirmwareVersion(Handle, ref FirmwareVersion);

                if (Library.Time() >= BatteryTimer)
                {
                    BatteryTimer = Library.Time() + 1000;
                    Console.WriteLine("Booted = {0}, Connected = {1}", IsBooted, IsConnected);
                    if (IsBooted && IsConnected)
                    {
                        Frames.SensorsBatteryGet(Handle);
                    }
                }

                Library.Tick();

                Frame frame = new Frame();

                while (Library.Receive(ref frame) == 1)
                {
                    switch (frame.Type)
                    {
                        case Frame.kSendFrame:
                        {
                            String evt;
                            if (listens.TryGetValue(frame.Reference, out evt))
                            {
                                T.Trigger(evt, frame);
                            }

                            if (frame.Reference == Symbols.kSensorsBatteryGet)
                            {
                                Z.LastBattery = frame.Get(Symbols.kCharge);
                                Console.WriteLine("Battery = {0}", Z.LastBattery);
                                A.Trigger("battery", Z.LastBattery);
                            }
                        }
                            break;
                        case Frame.kConnectFrame:
                            {
                                Console.WriteLine("Connect Frame");
                            }
                            break;
                        case Frame.kDisconnectFrame:
                            {
                                Console.WriteLine("Disconnect Frame");
                            }
                            break;
                        case Frame.kFlyStateFrame:
                            {
                                Console.WriteLine("Fly State Frame");
                            }
                            break;
                        case Frame.kFirmware:
                            {
                                Console.WriteLine("Firmware Frame");
                            }
                            break;
                        case Frame.kServerConnectivity:
                            {
                                Console.WriteLine("Server Connectivity Frame");
                            }
                            break;
                    }
                }

                Library.Status status;

                while ((status = Library.GetStatus()) != Library.Status.None)
                {
                    Console.WriteLine("Status = {0}", status);

                    switch (status)
                    {
                        case Library.Status.None:
                            break;
                        case Library.Status.FlashingStarted:
                            Internal.Connect.Trigger("firmware_upgrade_start");
                            A.Trigger("firmware_upgrade_start");
                            break;
                        case Library.Status.FlashingProcessSucessfull:
                            Internal.Connect.Trigger("firmware_upgrade_start_complete");
                            A.Trigger("firmware_upgrade_start_complete");
                            break;
                        case Library.Status.FlashingProcessFailed:
                            Internal.Connect.Trigger("firmware_upgrade_start_failed");
                            A.Trigger("firmware_upgrade_start_failed");
                            break;
                        case Library.Status.FlashingProcessInProgress:
                            Internal.Connect.Trigger("firmware_upgrade_in_progress");
                            A.Trigger("firmware_upgrade_in_progress");
                            break;
                        case Library.Status.ConfigurationStarting:
                            break;
                        case Library.Status.ConfigurationApplied:
                            break;
//.........这里部分代码省略.........
开发者ID:torquing,项目名称:ZanoFineTuning,代码行数:101,代码来源:ZanoHandler.cs

示例3: CalculatePressure

        public static void CalculatePressure(Frame f, PressureReading r)
        {
            //G.AccelerationNowX[index] = f.Get(Symbols.kX);
            double altitude = f.Get(Symbols.kAltitude);

            //G.FilteredAccelerationX[index] = U.LowPass(G.FilteredAccelerationX[index], G.AccelerationNowX[index], K.D);
            r.Altitude = U.LowPass(r.Altitude, altitude, K.D);

            //if (G.Readings[index] == 0)
            if (r.Readings == 0)
            {
                //G.FilteredAccelerationX[index] = G.AccelerationNowX[index];
                r.Altitude = altitude;

            }

            //double hpX = G.AccelerationNowX[index] - G.FilteredAccelerationX[index];
            double hpAltitude = altitude - r.Altitude;

            //double D = G.Readings[index] - K.DiscardUnder;
            double D = 35.0f;

            //if (hpX > G.FilteredAccelerationMaxX[index])
            //    G.FilteredAccelerationMaxX[index] = hpX;
            if (hpAltitude > r.MaxAltitude)
                r.MaxAltitude = hpAltitude;

            //if (hpX < G.FilteredAccelerationMinX[index])
            //    G.FilteredAccelerationMinX[index] = hpX;
            if (hpAltitude < r.MinAltitude)
                r.MinAltitude = hpAltitude;

            //if (G.Readings[index] >= K.DiscardUnder || G.MotorIndex == 4)
            //            if (r.Readings >= K.DiscardUnder || r == G.WaitReading)
            //            {
                //G.FilteredAccelerationMaxX[index] *= (D / (D+1.0));
                r.MaxAltitude *= (D / (D + 1.0));

                //G.FilteredAccelerationMinX[index] *= (D / (D+1.0));
                r.MinAltitude *= (D / (D + 1.0));

            //            }

            //if (G.Readings[index] >= K.DiscardUnder)
            //            if (r.Readings >= K.DiscardUnder)
            //            {

                //double rangeX = G.FilteredAccelerationMaxX[index] - G.FilteredAccelerationMinX[index];
                double rangeAltitude = r.MaxAltitude - r.MinAltitude;

                //G.RangeX[index] = U.LowPass(G.RangeX[index], rangeX, 10.0);
                r.RangeAltitude = U.LowPass(r.RangeAltitude, rangeAltitude, 10.0);

            //
            //                //G.Rating[index] = 5.0 - ((((G.RangeX[index] + G.RangeY[index])*0.5)-200.0)/70.0);
            //                r.RawRating = 5.0 - ((((r.RangeX + r.RangeY) * 0.5) - 200.0) / 70.0);
            //
            //                //if (G.Rating[index] > 5.0)
            //                if (r.RawRating > 5.0)
            //                    //G.Rating[index] = 5.0;
            //                    r.RawRating = 5.0;
            //                //else if (G.Rating[index] < 0.0)
            //                else if (r.RawRating < 0.0)
            //                    //G.Rating[index] = 0.0;
            //                    r.RawRating = 0.0;
            //
            //                ///// G.AllRatings[index] += G.Rating[index];
            //                //G.AvgRatings[index] = U.LowPass(G.AvgRatings[index], G.Rating[index], 10.0);  //G.AllRatings[index]/G.Readings[index];
            //                //r.Rating = U.LowPass(r.Rating, r.RawRating, 10.0);
            //                r.Rating = U.LowPass(r.Rating, r.RawRating, 20.0);

            //            }
        }
开发者ID:torquing,项目名称:ZanoFineTuning,代码行数:73,代码来源:Pressure.cs

示例4: ResetReadings

        /*
        public static void ResetReadings(int index)
        {
            G.AccelerationNowX[index] = 0;
            G.AccelerationNowY[index] = 0;
            G.FilteredAccelerationX[index] = 0;
            G.FilteredAccelerationY[index] = 0;
            G.FilteredAccelerationMinX[index] = 0;
            G.FilteredAccelerationMinY[index] = 0;
            G.FilteredAccelerationMaxX[index] = 0;
            G.FilteredAccelerationMaxY[index] = 0;
            G.RangeX[index] = 0;
            G.RangeY[index] = 0;
            G.Rating[index] = 0;
            G.AllRatings[index] = 0;
            G.AvgRatings[index] = 0;
            G.Readings[index] = 0;
        }
        */
        public static void CalculateVibration(Frame f, MotorReading r)
        {
            //G.AccelerationNowX[index] = f.Get(Symbols.kX);
            double x = f.Get(Symbols.kX);

            //G.AccelerationNowY[index] = f.Get(Symbols.kY);
            double y = f.Get(Symbols.kY);

            //G.FilteredAccelerationX[index] = U.LowPass(G.FilteredAccelerationX[index], G.AccelerationNowX[index], K.D);
            r.X = U.LowPass(r.X, x, K.D);

            //G.FilteredAccelerationY[index] = U.LowPass(G.FilteredAccelerationY[index], G.AccelerationNowY[index], K.D);
            r.Y = U.LowPass(r.Y, y, K.D);

            //if (G.Readings[index] == 0)
            if (r.Readings == 0)
            {
                //G.FilteredAccelerationX[index] = G.AccelerationNowX[index];
                r.X = x;

                //G.FilteredAccelerationY[index] = G.AccelerationNowY[index];
                r.Y = y;
            }

            //double hpX = G.AccelerationNowX[index] - G.FilteredAccelerationX[index];
            double hpX = x - r.X;

            //double hpY = G.AccelerationNowY[index] - G.FilteredAccelerationY[index];
            double hpY = y - r.Y;

            //double D = G.Readings[index] - K.DiscardUnder;
            double D = r.Readings - K.DiscardUnder;

            if (D < 0)
            {
                D = 0;
            }

            //if (D > 30.0)
            if (D > 45.0)
            {
                // D = 30.0;
                D = 45.0;
            }

            //if (hpX > G.FilteredAccelerationMaxX[index])
            //    G.FilteredAccelerationMaxX[index] = hpX;
            if (hpX > r.MaxX)
                r.MaxX = hpX;

            //if (hpY > G.FilteredAccelerationMaxY[index])
            //    G.FilteredAccelerationMaxY[index] = hpY;
            if (hpY > r.MaxY)
                r.MaxY = hpY;

            //if (hpX < G.FilteredAccelerationMinX[index])
            //    G.FilteredAccelerationMinX[index] = hpX;
            if (hpX < r.MinX)
                r.MinX = hpX;

            //if (hpY < G.FilteredAccelerationMinY[index])
            //    G.FilteredAccelerationMinY[index] = hpY;
            if (hpY < r.MinY)
                r.MinY = hpY;

            //if (G.Readings[index] >= K.DiscardUnder || G.MotorIndex == 4)
            if (r.Readings >= K.DiscardUnder || r == G.WaitReading)
            {
                //G.FilteredAccelerationMaxX[index] *= (D / (D+1.0));
                r.MaxX *= (D/(D + 1.0));

                //G.FilteredAccelerationMaxY[index] *= (D / (D+1.0));
                r.MaxY *= (D/(D + 1.0));

                //G.FilteredAccelerationMinX[index] *= (D / (D+1.0));
                r.MinX *= (D/(D + 1.0));

                //G.FilteredAccelerationMinY[index] *= (D / (D+1.0));
                r.MinY *= (D/(D + 1.0));
            }

//.........这里部分代码省略.........
开发者ID:torquing,项目名称:ZanoFineTuning,代码行数:101,代码来源:Vibration.cs


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