Example #1
0
        //    This event receives estimation results from other devices in the server room. In order
        //    to receive anything, make sure you call startUDP to connect to a room. Again, it provides
        //    access to a MotionDna object, which can be unpacked the same way as above.
        //
        //
        //    If you aren't receiving anything, then the room may be full, or there may be an error in
        //    your connection. See the reportError event below for more information.
        public void ReceiveNetworkData(MotionDna motionDna)
        {
            networkUsers[motionDna.ID] = motionDna;
            double timeSinceBootSeconds = SystemClock.ElapsedRealtime() / 1000.0;

            networkUsersTimestamps[motionDna.ID] = timeSinceBootSeconds;
            StringBuilder activeNetworkUsersStringBuilder = new StringBuilder();
            List <string> toRemove = new List <string>();

            activeNetworkUsersStringBuilder.Append("Network Shared Devices:\n");
            foreach (MotionDna user in networkUsers.Values)
            {
                if (timeSinceBootSeconds - networkUsersTimestamps[user.ID] > 2.0)
                {
                    toRemove.Add(user.ID);
                }
                else
                {
                    activeNetworkUsersStringBuilder.Append(user.DeviceName);
                    MotionDna.XYZ location = user.GetLocation().LocalLocation;
                    activeNetworkUsersStringBuilder.Append(string.Format(" ({0:2F}, {1:2F}, {2:2F})", location.X, location.Y, location.Z));
                    activeNetworkUsersStringBuilder.Append("\n");
                }
            }
            foreach (string key in toRemove)
            {
                networkUsers.Remove(key);
                networkUsersTimestamps.Remove(key);
            }

            networkTextView.Text = activeNetworkUsersStringBuilder.ToString();
        }
Example #2
0
        //    This event receives the estimation results using a MotionDna object.
        //    Check out the Getters section to learn how to read data out of this object.
        public void ReceiveMotionDna(MotionDna motionDna)
        {
            string str = "Navisens MotionDna Location Data:\n";

            str += "Lat: " + motionDna.GetLocation().GlobalLocation.Latitude + " Lon: " + motionDna.GetLocation().GlobalLocation.Longitude + "\n";
            MotionDna.XYZ location = motionDna.GetLocation().LocalLocation;
            str += string.Format(" ({0:F}, {1:F}, {2:F})\n", location.X, location.Y, location.Z);
            str += "Hdg: " + motionDna.GetLocation().Heading + " \n";
            str += "motionType: " + motionDna.GetMotion().MotionType + "\n";
            textView.SetTextColor(Color.Black);
            RunOnUiThread(() => { textView.Text = str; });
        }
Example #3
0
        public void Receive(MotionDna motionDna)
        {
            var location       = motionDna.Location;
            var localLocation  = location.localLocation;
            var globalLocation = location.globalLocation;
            var motion         = motionDna.Motion;

            var motionDnaLocalString      = string.Format("Local XYZ Coordinates (meters) \n({0:F}, {1:F}, {2:F})", localLocation.x, localLocation.y, localLocation.z);
            var motionDnaHeadingString    = string.Format("Current Heading: {0:F}", location.heading);
            var motionDnaGlobalString     = string.Format("Global Position: \n(Lat: {0:F}, Lon: {1:F})", globalLocation.latitude, globalLocation.longitude);
            var motionDnaMotionTypeString = string.Format("Motion Type: {0}", motion.motionType.ToString());

            var motionDnaString = string.Format("MotionDna Location:\n{0}\n{1}\n{2}\n{3}", motionDnaLocalString,
                                                motionDnaHeadingString,
                                                motionDnaGlobalString,
                                                motionDnaMotionTypeString);

            DispatchQueue.MainQueue.DispatchAsync(() => { this.receiveMotionDnaTextField.Text = motionDnaString; });
        }
Example #4
0
        public void ReceiveNetworkData(MotionDna motionDna)
        {
            var motionData = new MotionData(motionDna.ID, motionDna.DeviceName, motionDna.Location, motionDna.Motion.motionType);

            networkUsers[motionDna.ID] = motionData;
            var timeSinceBootSeconds = NSProcessInfo.ProcessInfo.SystemUptime;

            networkUsersTimestamps[motionDna.ID] = timeSinceBootSeconds;
            StringBuilder activeNetworkUsersString = new StringBuilder();
            List <string> toRemove = new List <string>();

            activeNetworkUsersString.Append("Network Shared Devices:\n");
            foreach (MotionData user in networkUsers.Values)
            {
                if (timeSinceBootSeconds - networkUsersTimestamps[user.id] > 2.0)
                {
                    toRemove.Add(user.id);
                }
                else
                {
                    activeNetworkUsersString = activeNetworkUsersString.Append(user.deviceName);
                    var location = user.location.localLocation;
                    activeNetworkUsersString.Append(string.Format(" ({0:2F}, {1:2F}, {2:2F})\n", location.x, location.y, location.z));
                }
            }

            foreach (string key in toRemove)
            {
                networkUsers.Remove(key);
                networkUsersTimestamps.Remove(key);
            }

            DispatchQueue.MainQueue.DispatchAsync(() => {
                receiveNetworkDataTextField.Text = activeNetworkUsersString.ToString();
            });
        }
Example #5
0
 public override void ReceiveNetworkData(MotionDna motionDna)
 {
     receiver?.ReceiveNetworkData(motionDna);
 }
Example #6
0
 public override void ReceiveMotionDna(MotionDna motionDna)
 {
     receiver.Receive(motionDna);
 }