// 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(); }
// 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; }); }