Beispiel #1
0
        private async Task SendAccMsg(AccelerometerReading accelerometerReading)
        {
            Vector3 acceleration = accelerometerReading.Acceleration;

            if (post)
            {
                string strr = "{'aX':" + acceleration.X.ToString("0.00") + ",'aY':" + acceleration.Y.ToString("0.00") + ",'aZ':" + acceleration.Z.ToString("0.00") + "}";
                string s    = await pb.sender(strr);

                accstateOutput.Dispatcher.BeginInvoke(() =>
                {
                    accstateOutput.Text = "加速度: " + s + "  No." + (++indexacc).ToString() + " message";
                });
            }
        }
Beispiel #2
0
        async void _motion_CurrentValueChanged(object sender, SensorReadingEventArgs <MotionReading> e)
        {
            AttitudeReading attitude           = e.SensorReading.Attitude;
            Vector3         deviceAcceleration = e.SensorReading.DeviceAcceleration;
            Vector3         deviceRotationRate = e.SensorReading.DeviceRotationRate;
            Vector3         gravity            = e.SensorReading.Gravity;

            String showstr = "";

            // 在 UI 上显示相关参数
            showstr  = "yaw: " + MathHelper.ToDegrees(attitude.Yaw).ToString("0.0");
            showstr += Environment.NewLine;
            showstr += "pitch: " + MathHelper.ToDegrees(attitude.Pitch).ToString("0.0");
            showstr += Environment.NewLine;
            showstr += "roll: " + MathHelper.ToDegrees(attitude.Roll).ToString("0.0");
            showstr += Environment.NewLine;
            showstr += "deviceAcceleration: \n" + deviceAcceleration.ToString();
            showstr += Environment.NewLine;
            showstr += "deviceRotationRate: \n" + deviceRotationRate.ToString();
            showstr += Environment.NewLine;
            showstr += "Gravity: \n" + gravity.ToString();
            showstr += Environment.NewLine;
            showstr += e.SensorReading.Timestamp;
            lblMsg.Dispatcher.BeginInvoke(() =>
            {
                lblMsg.Text = "MotionReading:\n" + showstr;
            });

            if (post)
            {
                String poststr = "{'yaw':" + MathHelper.ToDegrees(attitude.Yaw).ToString("0.0") + ",'pitch':" + MathHelper.ToDegrees(attitude.Pitch).ToString("0.0") + ",'roll':" + MathHelper.ToDegrees(attitude.Roll).ToString("0.0") +


                                 ",'dacx':" + deviceAcceleration.X + ",'dacy':" + deviceAcceleration.Y + ",'dacz':" + deviceAcceleration.Z +
                                 ",'drx':" + deviceRotationRate.X + ",'dry':" + deviceRotationRate.Y + ",'drz':" + deviceRotationRate.Z +
                                 ",'gx':" + gravity.X + ",'gy':" + gravity.Y + ",'gz':" + gravity.Z + "}";
                string s = await pb1.sender(poststr);

                //string s = await pb1.sender("{ 'DeviceId':'dev-01', 'Temperature':" + (++index).ToString() + " }");
                PostMotionStatus.Dispatcher.BeginInvoke(() =>
                {
                    PostMotionStatus.Text = "Motion: " + s + "  No." + (++index).ToString() + " message";
                });
            }
        }